LinKit.Resilience
1.2.1
dotnet add package LinKit.Resilience --version 1.2.1
NuGet\Install-Package LinKit.Resilience -Version 1.2.1
<PackageReference Include="LinKit.Resilience" Version="1.2.1" />
<PackageVersion Include="LinKit.Resilience" Version="1.2.1" />
<PackageReference Include="LinKit.Resilience" />
paket add LinKit.Resilience --version 1.2.1
#r "nuget: LinKit.Resilience, 1.2.1"
#:package LinKit.Resilience@1.2.1
#addin nuget:?package=LinKit.Resilience&version=1.2.1
#tool nuget:?package=LinKit.Resilience&version=1.2.1
LinKit.Resilience
LinKit.Resilience provides an explicit async execution pipeline with retries, per-attempt timeout, optional circuit breaker, configurable transient-error filtering, and TimeProvider support for deterministic tests.
Install
dotnet add package LinKit.Resilience
Execute an operation
using LinKit.Core.Resilience;
using LinKit.Resilience;
var options = new ResilienceOptions
{
MaxRetries = 2, // additional attempts after the first call
RetryDelay = TimeSpan.FromMilliseconds(200),
MaxRetryDelay = TimeSpan.FromSeconds(3),
Backoff = BackoffType.Exponential,
Timeout = TimeSpan.FromSeconds(5),
BreakerFailureThreshold = 5,
BreakerDurationSeconds = 30,
ShouldRetry = exception => exception is HttpRequestException
};
var response = await ResiliencePipeline.ExecuteAsync(
"inventory-api",
cancellationToken => inventoryClient.GetAsync(productId, cancellationToken),
options,
cancellationToken);
The order is retry loop, circuit-breaker check, per-attempt timeout, then the action. A successful attempt resets the breaker. MaxRetries = 2 permits up to three attempts. A zero breaker threshold disables the breaker.
Cancellation and timeout
Caller cancellation is propagated and is not retried. A timeout cancels the token passed to the action and reports TimeoutException when the action responds to cancellation. An action that ignores its token may continue running after the pipeline times out; do not use this as a mechanism to forcibly stop non-cooperative work.
Retries can repeat side effects. Use only for operations that are idempotent or protected by an idempotency key, and configure ShouldRetry narrowly for transient errors. Circuit breaker state is held in a process-wide registry keyed by string; use unique, stable keys for independent dependencies.
DI registration
AddLinKitResilience() is available for service registration/composition. The pipeline itself is invoked explicitly with ResiliencePipeline.ExecuteAsync; adding the package does not automatically wrap CQRS handlers or apply attributes to requests.
Native AOT
The pipeline uses delegates and does not require dynamic code generation in its direct execution path. Validate the full app and provider composition with trimming/AOT analyzers and publish for the deployment RID.
License
MIT. See the repository 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 is compatible. 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
- LinKit.Core (>= 3.2.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
-
net8.0
- LinKit.Core (>= 3.2.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
-
net9.0
- LinKit.Core (>= 3.2.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.