Bsft.Idempotency
2.2.0
dotnet add package Bsft.Idempotency --version 2.2.0
NuGet\Install-Package Bsft.Idempotency -Version 2.2.0
<PackageReference Include="Bsft.Idempotency" Version="2.2.0" />
<PackageVersion Include="Bsft.Idempotency" Version="2.2.0" />
<PackageReference Include="Bsft.Idempotency" />
paket add Bsft.Idempotency --version 2.2.0
#r "nuget: Bsft.Idempotency, 2.2.0"
#:package Bsft.Idempotency@2.2.0
#addin nuget:?package=Bsft.Idempotency&version=2.2.0
#tool nuget:?package=Bsft.Idempotency&version=2.2.0
Bsft.Idempotency
Makes an unsafe HTTP endpoint safe to retry: a client sends an Idempotency-Key, and a repeat of
that request replays the first response instead of running again.
Install
dotnet add package Bsft.Idempotency
Requires Bsft.Core, Bsft.Http, Bsft.Data and Bsft.Instrumentation (pulled transitively) and
ASP.NET Core. Bsft.Idempotency.EFCore is the shared record store a host running more than one
replica needs.
Register
services.AddBsftIdempotency(options =>
{
options.ShouldRequireKey = true;
options.Retention = TimeSpan.FromHours(24);
});
// or bound from configuration, section "Bsft:Idempotency"
services.AddBsftIdempotency(configuration);
The pipeline half is a second call, and its position matters: app.UseBsftIdempotency() goes after
UseBsftDefaults(), after UseRouting() and after authentication. Then opt an endpoint in with
[Idempotent] on a controller action or .RequireIdempotency() on a minimal-API route group.
Configure
| Option | Default | Effect |
|---|---|---|
BsftIdempotencyOptions.HeaderName |
Idempotency-Key |
The request header the key is read from. |
BsftIdempotencyOptions.Methods |
POST |
Which methods the middleware considers. |
BsftIdempotencyOptions.ShouldRequireKey |
false |
When true, an opted-in endpoint without a key answers 428. |
BsftIdempotencyOptions.Retention |
24 h | How long a stored response is replayed. |
BsftIdempotencyOptions.InProgressTimeout |
60 s | After which an unfinished reservation is retryable. |
BsftIdempotencyOptions.InProgressRetryAfter |
1 s | The Retry-After on the in-progress 409, capped by the lease. |
BsftIdempotencyOptions.MaxBodyBytes |
1 MiB | Above which the request is refused with 413 rather than left unprotected. |
BsftIdempotencyOptions.MaxResponseBytes |
1 MiB | Above which the response is sent but not stored, so the key runs again. |
BsftIdempotencyOptions.MaxKeyLength |
255 | Longest key accepted; at most 512, the shared store's column. |
BsftIdempotencyOptions.CachedResponseHeaders |
Location, Content-Type |
The allowlist replayed with the body. |
BsftIdempotencyOptions.NonReplayableStatusCodes |
401, 403, 408, 429 | Client errors that run again instead of being replayed. |
BsftIdempotencyOptions.Mode |
Detached |
Detached or Enlisted; see the guarantee table on the topic page. |
Validation: ValidateOnStart rejects a blank header name, an empty method list, a non-positive
window, a MaxKeyLength outside 1–512, and an InProgressTimeout longer than Retention — the
last one because a reservation that outlived the replay window would be pruned while it was still
refusing concurrent requests.
Extend
IIdempotencyStore— where records live. The default is in-process and is not enough for two replicas;Bsft.Idempotency.EFCorereplaces it with a shared table.IIdempotencyFingerprintContributor— adds or removes a segment of the request fingerprint.IIdempotencyAuditSink— receives replay, key-reuse and in-progress decisions. The default discards them.
Documentation
Topic page: docs/idempotency.md. Conventions: docs/package-conventions.md.
| 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 is compatible. 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. |
-
net10.0
- Bsft.Core (>= 2.2.0)
- Bsft.Data (>= 2.2.0)
- Bsft.Http (>= 2.2.0)
- Bsft.Instrumentation (>= 2.2.0)
-
net8.0
- Bsft.Core (>= 2.2.0)
- Bsft.Data (>= 2.2.0)
- Bsft.Http (>= 2.2.0)
- Bsft.Instrumentation (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.19)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.19)
- Microsoft.Extensions.Options (>= 9.0.19)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Bsft.Idempotency:
| Package | Downloads |
|---|---|
|
Bsft.Idempotency.EFCore
BSFT Framework EF Core persistence for idempotency records: the shared store behind Idempotency-Key replay, its unique index and the sweeper |
GitHub repositories
This package is not used by any popular GitHub repositories.