Repository navigation
Add Redis coordination and idempotency - #197
Merged
Merged
Conversation
Replace hybrid-cache synchronization with renewable owner-checked leases and retained idempotency outcomes. Co-authored-by: Copilot App <[email protected]> Signed-off-by: Eric Sibly <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
When idempotency is optional and no key is supplied, the invocation cancellation token is dropped, preventing later cancellation from reaching the application callback and surrounding checks.
1 open issue
What changed in this PR
This PR addresses #196 by separating coordination from ordinary caching. It replaces HybridCache-based synchronization with renewable leases and adds retained idempotency outcomes for CoreEx hosts.
Changes:
- Introduces coordination and idempotency contracts, Redis operations, and explicit in-memory registration.
- Updates HTTP integration, Functions cancellation handling, client key formatting, samples, and templates.
- Adds regression coverage and documents migration, coordinated rollout, and failure boundaries.
| File | Description |
|---|---|
| tests/CoreEx.Test.Unit/Http/HttpRequestMessageExtensionsTests.cs | Tests quoted and escaped idempotency keys. |
| tests/CoreEx.Test.Unit/Http/HttpRequestBuilderTests.cs | Tests generated keys and explicit-header preservation. |
| tests/CoreEx.Test.Unit/Hosting/Synchronization/CoordinationLeaseTests.cs | Covers ownership loss and cleanup behavior. |
| tests/CoreEx.Test.Unit/GlobalUsing.cs | Adds coordination test imports. |
| tests/CoreEx.Redis.Test.Worker/Program.cs | Provides a cross-process coordination worker. |
| tests/CoreEx.Redis.Test.Worker/GlobalUsing.cs | Adds worker imports. |
| tests/CoreEx.Redis.Test.Worker/CoreEx.Redis.Test.Worker.csproj | Defines the non-packable test worker. |
| tests/CoreEx.Caching.Redis.Test.Unit/HybridCacheSynchronizerTests.cs | Removes obsolete synchronization tests. |
| tests/CoreEx.Caching.Redis.Test.Unit/GlobalUsing.cs | Adds shared test imports. |
| tests/CoreEx.Caching.Redis.Test.Unit/EntryPoint.cs | Registers Redis coordination for tests. |
| tests/CoreEx.Caching.Redis.Test.Unit/CoreEx.Caching.Redis.Test.Unit.csproj | References Redis coordination and its worker. |
| tests/CoreEx.Azure.Functions.TestApp/Program.cs | Uses in-memory idempotency storage. |
| tests/CoreEx.Azure.Functions.Test.Unit/FunctionsHttpIdempotencyTests.cs | Asserts uncertain outcomes block automatic retries. |
| tests/CoreEx.AspNetCore.Test.Unit/GlobalUsing.cs | Adds HTTP idempotency test imports. |
| tests/CoreEx.AspNetCore.Test.Api/Program.cs | Migrates test-host idempotency registration. |
| src/CoreEx/Idempotency/IIdempotencyStore.cs | Defines atomic attempts and reconciliation. |
| src/CoreEx/Idempotency/IIdempotencyAttempt.cs | Defines owned terminal-response completion. |
| src/CoreEx/Idempotency/IdempotencyOutcome.cs | Defines processing and replay decisions. |
| src/CoreEx/Idempotency/IdempotencyBeginResult.cs | Represents a coherent attempt result. |
| src/CoreEx/Idempotency/IdempotencyAttempt.cs | Implements lease-backed attempt lifetime. |
| src/CoreEx/Http/README.md | Documents quoted key serialization. |
| src/CoreEx/Http/IdempotencyKeyHeader.cs | Validates and formats logical keys. |
| src/CoreEx/Http/IdempotencyKeyHandler.cs | Quotes generated outgoing keys. |
| src/CoreEx/Hosting/SynchronizedTimerHostedServiceBase.cs | Links execution to lease ownership. |
| src/CoreEx/Hosting/Synchronization/ISynchronizer.cs | Removes the old enter/exit contract. |
| src/CoreEx/Hosting/Synchronization/HybridCacheSynchronizer.cs | Removes cache-based synchronization. |
| src/CoreEx/GlobalUsing.cs | Switches to coordination imports. |
| src/CoreEx/Extensions.HttpRequestMessage.cs | Formats explicitly supplied idempotency keys. |
| src/CoreEx/CoreExExtensions.DependencyInjection.cs | Adds in-memory coordination registration. |
| src/CoreEx/Coordination/SynchronizerExtensions.cs | Adds type-qualified lease acquisition. |
| src/CoreEx/Coordination/ISynchronizer.cs | Defines bounded lease acquisition. |
| src/CoreEx/Coordination/ISynchronizationLease.cs | Defines ownership loss and disposal. |
| src/CoreEx/Coordination/InMemoryCoordinationState.cs | Holds shared in-memory ownership records. |
| src/CoreEx/Coordination/CoordinationOptions.cs | Defines and validates ownership durations. |
| src/CoreEx/Caching/README.md | Separates caching from synchronization. |
| src/CoreEx.Template/README.md | Updates packaged guide counts. |
| src/CoreEx.Template/CoreEx.Template.csproj | Includes the Redis AI guide. |
| src/CoreEx.Template/content/CoreEx.Subscribe/src/app-name.Subscribe/Program.cs | Registers Redis-backed idempotency. |
| src/CoreEx.Template/content/CoreEx.Subscribe/src/app-name.Subscribe/app-name.Subscribe.csproj | Adds the Redis package reference. |
| src/CoreEx.Template/content/CoreEx.Subscribe/src/app-name.Subscribe/AGENTS.md | Documents separate coordination storage. |
| src/CoreEx.Template/content/CoreEx.Core/_Directory.Packages.props | Pins the generated Redis package version. |
| src/CoreEx.Template/content/CoreEx.Api/src/app-name.Api/Program.cs | Registers Redis-backed idempotency. |
| src/CoreEx.Template/content/CoreEx.Api/src/app-name.Api/app-name.Api.csproj | Adds the Redis package reference. |
| src/CoreEx.Template/content/CoreEx.Api/src/app-name.Api/AGENTS.md | Documents registration and key scoping. |
| src/CoreEx.Redis/Scripts/LeaseRenew.lua | Renews only the current owner's lease. |
| src/CoreEx.Redis/Scripts/LeaseRelease.lua | Releases only the current owner's lease. |
| src/CoreEx.Redis/Scripts/IdempotencyTransition.lua | Applies owner-checked state transitions. |
| src/CoreEx.Redis/Scripts/IdempotencyResolve.lua | Reconciles uncertain attempts by revision. |
| src/CoreEx.Redis/Scripts/IdempotencyBegin.lua | Atomically claims or reads an outcome. |
| src/CoreEx.Redis/GlobalUsing.cs | Defines Redis package imports. |
| src/CoreEx.Redis/CoreExRedisExtensions.cs | Registers scoped Redis providers. |
| src/CoreEx.Redis/CoreEx.Redis.csproj | Defines the Redis package and embedded scripts. |
| src/CoreEx.Redis/AGENTS.md | Documents usage and guarantee limits. |
| src/CoreEx.Caching.FusionCache/AGENTS.md | Removes cache-backed idempotency guidance. |
| src/CoreEx.Azure.Functions/FunctionsHttpExtensions.cs | Passes operation cancellation through idempotency. |
| src/CoreEx.Azure.Functions/AGENTS.md | Documents storage and uncertain outcomes. |
| src/CoreEx.AspNetCore/OpenApiOptions.cs | Describes structured-field key syntax. |
| src/CoreEx.AspNetCore/Idempotency/IIdempotencyProvider.cs | Adds invocation cancellation to the contract. |
| src/CoreEx.AspNetCore/Idempotency/IdempotencyKeyMiddleware.cs | Forwards request cancellation. |
| src/CoreEx.AspNetCore/GlobalUsing.cs | Updates HTTP integration imports. |
| src/CoreEx.AspNetCore/CoreExAspNetCoreExtensions.DependencyInjection.cs | Registers store-backed HTTP idempotency. |
| src/CoreEx.AspNetCore/AGENTS.md | Documents explicit provider registration. |
| src/CoreEx.AspNetCore.NSwag/README.md | Explains quoted keys and validation modes. |
| src/CoreEx.AspNetCore.NSwag/NSwagOpenApiOperationProcessor.cs | Removes wire-length constraints from key schemas. |
| samples/src/Contoso.Shopping.Subscribe/Program.cs | Migrates to Redis coordination. |
| samples/src/Contoso.Shopping.Subscribe/Contoso.Shopping.Subscribe.csproj | References CoreEx.Redis. |
| samples/src/Contoso.Shopping.Api/Program.cs | Migrates to Redis coordination. |
| samples/src/Contoso.Shopping.Api/Contoso.Shopping.Api.csproj | References CoreEx.Redis. |
| samples/src/Contoso.Products.Subscribe/Program.cs | Migrates to Redis coordination. |
| samples/src/Contoso.Products.Subscribe/Contoso.Products.Subscribe.csproj | References CoreEx.Redis. |
| samples/src/Contoso.Products.Api/Program.cs | Migrates to Redis coordination. |
| samples/src/Contoso.Products.Api/Contoso.Products.Api.csproj | References CoreEx.Redis. |
| samples/src/Contoso.Orders.Api/Program.cs | Migrates to Redis coordination. |
| samples/src/Contoso.Orders.Api/Contoso.Orders.Api.csproj | References CoreEx.Redis. |
| samples/src/Contoso.Customers.Api/Program.cs | Migrates to Redis coordination. |
| samples/src/Contoso.Customers.Api/Contoso.Customers.Api.csproj | References CoreEx.Redis. |
| samples/docs/hosts-layer.md | Explains host storage and replay behavior. |
| README.md | Introduces coordination and the Redis package. |
| nuget-publish.ps1 | Includes Redis in package publishing. |
| docs/capabilities.md | Clarifies bounded idempotency guarantees. |
| Directory.Packages.props | Pins StackExchange.Redis. |
| CoreEx.slnx | Includes Redis and its test worker. |
| CoreEx.Core.slnf | Includes Redis projects in the solution filter. |
| CHANGELOG.md | Records features and breaking migration steps. |
| AGENTS.md | Adds Redis to the package catalog. |
| .github/skills/coreex-functions/SKILL.md | Updates Functions idempotency guidance. |
| .github/skills/coreex-functions/references/workflow.md | Documents explicit storage and rollout limits. |
| .github/skills/coreex-functions/references/patterns.md | Updates replay and registration patterns. |
| .github/skills/coreex-docs-sync/README.md | Updates the bundled guide count. |
| .github/instructions/coreex-functions.instructions.md | Defines Functions coordination guidance. |
| .github/instructions/coreex-event-subscribers.instructions.md | Updates subscriber registration examples. |
| .github/coreex-ai-workflows.md | Updates package-guide coverage. |
| .github/copilot-instructions.md | Separates ordinary caching from idempotency. |
| .github/agents/README.md | Updates documentation-cache inventory. |
| .github/agents/coreex-expert.agent.md | Adds Redis guidance and clarifies FusionCache scope. |
Review effort: Balanced
Co-authored-by: Copilot App <[email protected]> Signed-off-by: Eric Sibly <[email protected]>
Co-authored-by: Copilot App <[email protected]> Signed-off-by: Eric Sibly <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Breaking changes
Replace the HybridCache synchronization and idempotency registrations with a coordination provider and
AddIdempotencyProvider(). Existing HybridCache receipts are not migrated; old and new replicas must not process the same protected operations concurrently.Validation
Closes #196