Muonroi.Resilience 1.0.0-alpha.16

This is a prerelease version of Muonroi.Resilience.
dotnet add package Muonroi.Resilience --version 1.0.0-alpha.16
                    
NuGet\Install-Package Muonroi.Resilience -Version 1.0.0-alpha.16
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Muonroi.Resilience" Version="1.0.0-alpha.16" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Muonroi.Resilience" Version="1.0.0-alpha.16" />
                    
Directory.Packages.props
<PackageReference Include="Muonroi.Resilience" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Muonroi.Resilience --version 1.0.0-alpha.16
                    
#r "nuget: Muonroi.Resilience, 1.0.0-alpha.16"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Muonroi.Resilience@1.0.0-alpha.16
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Muonroi.Resilience&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Muonroi.Resilience&version=1.0.0-alpha.16&prerelease
                    
Install as a Cake Tool

Muonroi.Resilience

Polly-based resilience patterns for Muonroi services: retry, circuit breaker, and timeout policies with built-in OpenTelemetry integration.

NuGet License: Apache 2.0

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 MTransientException and HttpRequestException; each attempt increments the muonroi.retry.attempts OTel 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 typed ResiliencePipeline<T> instances with the same defaults when you need a pipeline outside of the ResiliencePipelineProvider abstraction.
  • OTel metrics — retry attempts reported via MuonroiMetrics.RetryAttemptCount (meter Muonroi.Ecosystem.Core, instrument muonroi.retry.attempts), tagged with exception.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, MTransientException retry triggers, circuit-breaker fast-fail, and OTel metrics

Compatibility

  • Target framework: net8.0
  • License: Apache-2.0 (OSS)

License

Apache-2.0. See LICENSE-APACHE.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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