Bsft.Resilience.Mediator
2.2.0
dotnet add package Bsft.Resilience.Mediator --version 2.2.0
NuGet\Install-Package Bsft.Resilience.Mediator -Version 2.2.0
<PackageReference Include="Bsft.Resilience.Mediator" Version="2.2.0" />
<PackageVersion Include="Bsft.Resilience.Mediator" Version="2.2.0" />
<PackageReference Include="Bsft.Resilience.Mediator" />
paket add Bsft.Resilience.Mediator --version 2.2.0
#r "nuget: Bsft.Resilience.Mediator, 2.2.0"
#:package Bsft.Resilience.Mediator@2.2.0
#addin nuget:?package=Bsft.Resilience.Mediator&version=2.2.0
#tool nuget:?package=Bsft.Resilience.Mediator&version=2.2.0
Bsft.Resilience.Mediator
The behavior package of the Bsft.Resilience family: a mediator pipeline behavior that retries
requests marked with [Retryable] on transient failures, over a Polly pipeline built once per
process.
Install
dotnet add package Bsft.Resilience.Mediator
Requires Bsft.Mediator.Abstractions, Bsft.Core and Polly.Core (all pulled transitively). It
does not reference Bsft.Resilience: the HTTP half and the mediator half share a name and
nothing else, so a host retrying commands takes neither the HTTP resilience stack nor the
correlation handler along.
Register
services.AddBsftResilienceMediator(options =>
{
options.MaxRetryAttempts = 3;
});
// or bound from configuration, section "Bsft:Resilience:Mediator"
services.AddBsftResilienceMediator(configuration);
Then mark the requests that may safely run twice:
[Retryable]
public sealed record SyncProductPriceQuery(Guid ProductId) : IQuery<decimal>;
With UseDefaults() the position is the framework's, not the registration order: retry runs outside
the transaction behavior, so each attempt gets its own transaction, and inside authorization,
validation and audit, which therefore run once per request. Without UseDefaults(), registration
order is the pipeline order, so call this after AddBsftMediator. Apply the marker only to
idempotent requests — retrying a command with side effects duplicates them.
Configure
| Option | Default | Effect |
|---|---|---|
BsftResilienceMediatorOptions.MaxRetryAttempts |
3 |
Retries performed after the initial invocation. |
BsftResilienceMediatorOptions.BaseDelay |
200ms |
Base delay between retries; grows exponentially and is randomized with jitter. |
BsftResilienceMediatorOptions.ShouldRetry |
IsTransientFailure |
Decides which exception is transient. The default retries everything except cancellation and the deterministic Bsft.Core domain exceptions (validation, business rule, not found, forbidden, conflict). |
Validation: a negative retry count, a negative delay and a null predicate are rejected at
registration and again on ValidateOnStart, each naming the member and the offending value.
ShouldRetry has no configuration binding — it is a delegate — so a section can set the first two
members only.
Extend
IMediatorResiliencePipelineProvider — supplies the shared ResiliencePipeline the behavior
executes through. The default builds it once from the options and reuses it; replace the
registration to run requests through a pipeline this package cannot describe (a bulkhead, a
hedging strategy, a circuit breaker over the mediator).
Documentation
Topic page: docs/resilience.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.Mediator.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Options (>= 10.0.12)
- Polly.Core (>= 8.7.0)
-
net8.0
- Bsft.Core (>= 2.2.0)
- Bsft.Mediator.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Configuration.Binder (>= 9.0.19)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.19)
- Microsoft.Extensions.Options (>= 9.0.19)
- Polly.Core (>= 8.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.