CoreSystem.Idempotency
2.0.1
See the version list below for details.
dotnet add package CoreSystem.Idempotency --version 2.0.1
NuGet\Install-Package CoreSystem.Idempotency -Version 2.0.1
<PackageReference Include="CoreSystem.Idempotency" Version="2.0.1" />
<PackageVersion Include="CoreSystem.Idempotency" Version="2.0.1" />
<PackageReference Include="CoreSystem.Idempotency" />
paket add CoreSystem.Idempotency --version 2.0.1
#r "nuget: CoreSystem.Idempotency, 2.0.1"
#:package CoreSystem.Idempotency@2.0.1
#addin nuget:?package=CoreSystem.Idempotency&version=2.0.1
#tool nuget:?package=CoreSystem.Idempotency&version=2.0.1
⚡ CoreSystem.Idempotency
Production-ready idempotency for ASP.NET Core that suppresses concurrent duplicates and replays persisted responses.
CoreSystem.Idempotency is a middleware-based idempotency framework for distributed applications. It fingerprints incoming requests, persists successful responses through pluggable storage providers, and replays completed operations instead of executing them twice.
✨ Features
- ✅ ASP.NET Core middleware
- ✅ Concurrent duplicate suppression
- ✅ Response replay from persisted entries
- ✅ Request fingerprint validation
- ✅ Duplicate request detection
- ✅ Provider-independent storage architecture
- ✅ Configurable expiration, methods and fingerprinting
- ✅ Built-in OpenTelemetry metrics
- ✅ Extensible through
IIdempotencyStorage
📦 Installation
Install the framework, then a storage provider. A provider is required.
dotnet add package CoreSystem.Idempotency
| Package | Purpose |
|---|---|
| CoreSystem.Idempotency.Redis | Redis-based distributed storage |
| CoreSystem.Idempotency.PostgreSql | PostgreSQL-based durable storage |
Additional providers can be implemented through the IIdempotencyStorage abstraction.
🚀 Quick Start
Register the framework.
builder.Services
.AddCoreIdempotency(options =>
{
builder.Configuration
.GetSection("Core:Idempotency")
.Bind(options);
});
Register a storage provider. Both providers require a configuration delegate.
builder.Services.AddCoreIdempotencyRedis(options =>
{
options.Configuration = redis =>
{
redis.EndPoints.Add("localhost:6379");
};
});
builder.Services.AddCoreIdempotencyPostgreSql(options =>
{
options.ConnectionString =
builder.Configuration.GetConnectionString("Idempotency");
});
Enable the middleware.
app.UseCoreIdempotency();
Configure through the Core:Idempotency section.
{
"Core": {
"Idempotency": {
"Enabled": true,
"InstanceName": "Orders",
"Expiration": "06:00:00",
"AllowedMethods": [ "POST", "PUT" ]
}
}
}
🔒 How It Works
Incoming Request
│
▼
Resolve Idempotency Key
│
▼
Generate Request Fingerprint
│
▼
Lookup IIdempotencyStorage
│
┌─────┴─────┐
│ │
Found Not Found
│ │
▼ ▼
Replay Execute Endpoint
Response │
▼
Persist Response
Every duplicate request receives the original response without executing the application endpoint again.
📊 Built-in Observability
OpenTelemetry metrics are published out of the box: request processing, cache hits and misses, response replay, storage read and write latency, and persisted payload size.
Compatible with OpenTelemetry, Prometheus, Grafana, Azure Monitor, Jaeger, Elastic and Datadog.
🏗 Architecture
CoreSystem.Idempotency coordinates the idempotency workflow while remaining completely independent from storage implementations.
ASP.NET Core
│
▼
CoreSystem.Idempotency
│
▼
IIdempotencyStorage
│
┌────┴────┐
▼ ▼
Redis PostgreSQL
Future Providers
This provider-based architecture allows new storage implementations to be introduced without modifying the core framework.
📚 Documentation
- Getting Started
- Architecture and configuration
- Storage providers: Redis, PostgreSQL
- Delivery guarantees
- Fingerprinting and response replay
- Observability and error reference
🤝 Contributing
Contributions, bug reports, feature requests and new storage providers are always welcome. Fork the repository, create a feature branch, and open a pull request.
📄 License
Released under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- CoreSystem.Http (>= 1.1.0)
- CoreSystem.Observability.Abstractions (>= 1.0.1)
- CoreSystem.Serialization (>= 1.2.3)
- OpenTelemetry.Extensions.Hosting (>= 1.19.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CoreSystem.Idempotency:
| Package | Downloads |
|---|---|
|
CoreSystem.Idempotency.Redis
Production-ready Redis storage provider for CoreSystem.Idempotency, providing high-performance distributed persistence through the IIdempotencyStorage abstraction. |
|
|
CoreSystem.Idempotency.PostgreSql
Production-ready PostgreSQL storage provider for CoreSystem.Idempotency, providing durable persistence through the IIdempotencyStorage abstraction with Dapper-based data access. Ships an idempotent schema script at scripts/postgres.sql. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Corrections release. 2.0.0 shipped documentation that did not compile and a
PostgreSQL schema missing its state and lease_id columns:
- AddCoreIdempotencyRedis and AddCoreIdempotencyPostgreSql examples in the README
showed a parameterless call; both methods require a configuration delegate.
The provider never created its schema. The documented idempotency_keys table
predated the lease contract and failed on the first request.
The PostgreSQL package now ships scripts/postgres.sql.
Also: XML documentation is published, SourceLink is enabled, and the package
metadata URLs were corrected.