Muonroi.Resilience
2.0.2
dotnet add package Muonroi.Resilience --version 2.0.2
NuGet\Install-Package Muonroi.Resilience -Version 2.0.2
<PackageReference Include="Muonroi.Resilience" Version="2.0.2" />
<PackageVersion Include="Muonroi.Resilience" Version="2.0.2" />
<PackageReference Include="Muonroi.Resilience" />
paket add Muonroi.Resilience --version 2.0.2
#r "nuget: Muonroi.Resilience, 2.0.2"
#:package Muonroi.Resilience@2.0.2
#addin nuget:?package=Muonroi.Resilience&version=2.0.2
#tool nuget:?package=Muonroi.Resilience&version=2.0.2
Muonroi.Resilience
Polly-based resilience patterns optimized for Muonroi with built-in telemetry tracking.
Overview
The Muonroi.Resilience package provides a standardized approach to fault tolerance in distributed systems using Polly. In a microservices architecture, transient failures (e.g., brief network outages, temporary database unavailability) are common. This package abstracts the setup of robust Retry, Circuit Breaker, Timeout, and Bulkhead policies.
Crucially, it extends standard Polly functionality by integrating deeply with Muonroi's telemetry ecosystem. State transitions (e.g., a Circuit Breaker opening) and execution retries are automatically logged and emitted as OpenTelemetry metrics, ensuring full visibility into the stability of downstream dependencies.
Use this package when your application needs to reliably communicate with external APIs, databases, or message brokers over unreliable networks.
Features
- Pre-configured Resilience Pipelines: Offers
AddMuonroiResilience()which registers standard policy wrappers tailored for common scenarios. - Retry Policies: Automatically retries failed operations using configurable exponential backoff strategies to avoid overwhelming struggling services, explicitly handling
MTransientException. - Circuit Breaker: Detects when a downstream service is fundamentally unhealthy and fails fast, preventing cascading failures across the system.
- Timeouts: Ensures that slow dependencies don't consume all available threads in the calling application via
AddTimeout. - Telemetry Integration: Policy executions and state changes automatically emit OTel events and structured logs via
MuonroiMetrics.RetryAttemptCountandIMLog.
Installation
dotnet add package Muonroi.Resilience
Quick Start
Basic Configuration
Register the standard Muonroi resilience policies in your dependency injection container. This will make the ResiliencePipelineProvider available to your services.
using Microsoft.Extensions.DependencyInjection;
using Muonroi.Resilience;
var builder = WebApplication.CreateBuilder(args);
// Register standard resilience pipeline ("muonroi-standard")
builder.Services.AddMuonroiResilience();
Manual Policy Execution
If you need to wrap arbitrary code (e.g., a database connection attempt or a file system operation) in a resilience policy, you can resolve the ResiliencePipelineProvider.
using Polly.Registry;
using System.Threading.Tasks;
public class DatabaseInitializer
{
private readonly ResiliencePipelineProvider<string> _pipelineProvider;
public DatabaseInitializer(ResiliencePipelineProvider<string> pipelineProvider)
{
_pipelineProvider = pipelineProvider;
}
public async Task InitializeAsync()
{
// Get the predefined 'muonroi-standard' pipeline
var pipeline = _pipelineProvider.GetPipeline("muonroi-standard");
// Execute the unstable operation within the pipeline
await pipeline.ExecuteAsync(async token =>
{
await RunMigrationLogicAsync();
});
}
}
API Reference
Configuration Extensions
MuonroiResilienceExtensions: ContainsAddMuonroiResilience()which populates the DI container withResiliencePipelineBuilderconfigurations standard to the ecosystem.
Pipeline Handlers
PolicyHandler: Internal handlers that wire Polly's events to Muonroi'sIMLogand OpenTelemetry metrics abstractions.
Ecosystem Combinations
+ Muonroi.Observability → Resiliency Metrics
By combining these, Polly events such as retries are automatically intercepted and exported via MuonroiMetrics.RetryAttemptCount, allowing operators to set up Grafana alerts when internal services begin to destabilize before complete failure.
+ Muonroi.Logging.Abstractions → Structured Resilience Logs
The resilience pipeline extracts IMLog from the IServiceProvider at runtime to emit structured logs containing the precise exception types and retry attempts when a transient error is caught and retried.
Full Resilience Stack
builder.Services
.AddMuonroiResilience()
.AddMuonroiObservability(config);
Samples
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 (>= 2.0.2)
- Muonroi.Logging.Abstractions (>= 2.0.2)
- Muonroi.Observability (>= 2.0.2)
- 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 |
|---|---|---|
| 2.0.2 | 146 | 8/26/2026 |
| 2.0.1 | 152 | 8/26/2026 |
| 2.0.0 | 182 | 8/14/2026 |
| 1.0.0-alpha.2 | 73 | 3/26/2026 |