Muonroi.Resilience
1.0.0-alpha.16
dotnet add package Muonroi.Resilience --version 1.0.0-alpha.16
NuGet\Install-Package Muonroi.Resilience -Version 1.0.0-alpha.16
<PackageReference Include="Muonroi.Resilience" Version="1.0.0-alpha.16" />
<PackageVersion Include="Muonroi.Resilience" Version="1.0.0-alpha.16" />
<PackageReference Include="Muonroi.Resilience" />
paket add Muonroi.Resilience --version 1.0.0-alpha.16
#r "nuget: Muonroi.Resilience, 1.0.0-alpha.16"
#:package Muonroi.Resilience@1.0.0-alpha.16
#addin nuget:?package=Muonroi.Resilience&version=1.0.0-alpha.16&prerelease
#tool nuget:?package=Muonroi.Resilience&version=1.0.0-alpha.16&prerelease
Muonroi.Resilience
Polly-based resilience patterns for Muonroi services: retry, circuit breaker, and timeout policies with built-in OpenTelemetry integration.
This package wires up a production-ready Polly v8 resilience pipeline under the well-known name "muonroi-standard" and emits retry telemetry via MuonroiMetrics.RetryAttemptCount (muonroi.retry.attempts). It also exposes PolicyHandler for building typed ResiliencePipeline<T> instances directly when DI injection is not suitable. The package depends on Muonroi.Core.Abstractions, Muonroi.Logging.Abstractions, and Muonroi.Observability.
Installation
dotnet add package Muonroi.Resilience --prerelease
Quick Start
Register the standard pipeline in Program.cs:
using Muonroi.Resilience;
builder.Services.AddMuonroiResilience();
Resolve and execute via ResiliencePipelineProvider<string>:
using Polly.Registry;
public class WeatherApiClient(
ResiliencePipelineProvider<string> pipelines,
IHttpClientFactory factory)
{
public async Task<string> GetForecastAsync(CancellationToken ct)
{
ResiliencePipeline pipeline = pipelines.GetPipeline("muonroi-standard");
return await pipeline.ExecuteAsync(async token =>
{
HttpClient client = factory.CreateClient("weather-api");
HttpResponseMessage response = await client.GetAsync("forecast?latitude=21&longitude=105", token);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync(token);
}, ct);
}
}
You can also register additional named pipelines alongside "muonroi-standard":
using Polly;
using Polly.Retry;
using Muonroi.Core.Abstractions.Exceptions;
builder.Services.AddResiliencePipeline("payment-gateway", (pipelineBuilder, context) =>
{
pipelineBuilder
.AddRetry(new RetryStrategyOptions
{
ShouldHandle = new PredicateBuilder()
.Handle<MTransientException>()
.Handle<HttpRequestException>(),
BackoffType = DelayBackoffType.Exponential,
UseJitter = true,
MaxRetryAttempts = 5,
Delay = TimeSpan.FromSeconds(2)
})
.AddTimeout(TimeSpan.FromSeconds(30));
});
Features
AddMuonroiResilience()— registers the"muonroi-standard"named pipeline with retry, circuit breaker, and timeout chained in that order.- Retry — up to 3 attempts, exponential back-off with jitter, 1 s base delay; handles
MTransientExceptionandHttpRequestException; each attempt increments themuonroi.retry.attemptsOTel counter. - Circuit breaker — opens when the failure ratio reaches 50% over a 30 s / 5-call minimum window; stays open for 30 s; handles any
Exception. - Timeout — 10 s hard timeout per execution attempt.
PolicyHandler— builds typedResiliencePipeline<T>instances with the same defaults when you need a pipeline outside of theResiliencePipelineProviderabstraction.- OTel metrics — retry attempts reported via
MuonroiMetrics.RetryAttemptCount(meterMuonroi.Ecosystem.Core, instrumentmuonroi.retry.attempts), tagged withexception.type.
Configuration
There are no appsettings.json keys for the standard pipeline — all defaults are hardcoded in MuonroiResilienceExtensions.AddMuonroiResilience(). To customise thresholds, register additional named pipelines with AddResiliencePipeline(name, ...) from Polly.Extensions directly.
API Reference
| Type | Purpose |
|---|---|
MuonroiResilienceExtensions |
Static class; provides AddMuonroiResilience(this IServiceCollection) |
PolicyHandler |
Builds typed ResiliencePipeline<T> via CreateDefaultPipeline<T>(serviceName) with retry + circuit breaker + timeout |
Samples
- Quickstart.Resilience — full ASP.NET Core API demonstrating
AddMuonroiResilience(), custom named pipelines,PolicyHandler,MTransientExceptionretry triggers, circuit-breaker fast-fail, and OTel metrics
Compatibility
- Target framework:
net8.0 - License: Apache-2.0 (OSS)
Related Packages
Muonroi.Core.Abstractions— providesMTransientExceptionhandled by the retry predicateMuonroi.Logging.Abstractions— providesIMLog<T>used for retry and circuit-breaker event loggingMuonroi.Observability— providesMuonroiMetrics.RetryAttemptCountOTel counter
License
Apache-2.0. See LICENSE-APACHE.
| 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
- Muonroi.Core.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Logging.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Observability (>= 1.0.0-alpha.16)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.15.3)
- Polly (>= 8.5.2)
- Polly.Extensions (>= 8.5.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Muonroi.Resilience:
| Package | Downloads |
|---|---|
|
Muonroi.Http
HTTP client utilities for Muonroi: resilient client factory, tenant header propagation, and typed client base. |
|
|
Muonroi.BuildingBlock.All
Metapackage for Muonroi Building Block - Includes all sub-packages for a complete infrastructure setup. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.16 | 87 | 6/22/2026 |
| 1.0.0-alpha.15 | 125 | 5/31/2026 |
| 1.0.0-alpha.14 | 107 | 5/15/2026 |
| 1.0.0-alpha.13 | 89 | 5/2/2026 |
| 1.0.0-alpha.12 | 86 | 4/2/2026 |
| 1.0.0-alpha.11 | 129 | 4/2/2026 |
| 1.0.0-alpha.9 | 73 | 3/30/2026 |
| 1.0.0-alpha.8 | 164 | 3/28/2026 |
| 1.0.0-alpha.7 | 79 | 3/27/2026 |
| 1.0.0-alpha.5 | 74 | 3/27/2026 |
| 1.0.0-alpha.4 | 75 | 3/27/2026 |
| 1.0.0-alpha.3 | 68 | 3/27/2026 |
| 1.0.0-alpha.2 | 71 | 3/26/2026 |
| 1.0.0-alpha.1 | 85 | 3/8/2026 |