Franz.Common.Mediator.Polly
2.0.2
dotnet add package Franz.Common.Mediator.Polly --version 2.0.2
NuGet\Install-Package Franz.Common.Mediator.Polly -Version 2.0.2
<PackageReference Include="Franz.Common.Mediator.Polly" Version="2.0.2" />
<PackageVersion Include="Franz.Common.Mediator.Polly" Version="2.0.2" />
<PackageReference Include="Franz.Common.Mediator.Polly" />
paket add Franz.Common.Mediator.Polly --version 2.0.2
#r "nuget: Franz.Common.Mediator.Polly, 2.0.2"
#:package Franz.Common.Mediator.Polly@2.0.2
#addin nuget:?package=Franz.Common.Mediator.Polly&version=2.0.2
#tool nuget:?package=Franz.Common.Mediator.Polly&version=2.0.2
Franz.Common.Mediator.Polly
Franz.Common.Mediator.Polly extends Franz.Common.Mediator with Polly-based resilience pipelines. It gives you retry, circuit breaker, advanced circuit breaker, timeout, and bulkhead isolation for Mediator requests β all with enriched Serilog logging, context-awareness, and resilience telemetry built-in.
β‘ No extra wiring. No boilerplate. Just plug it in.
- Current Version: 2.0.2
- Target Frameworks: .NET 9+
- Dependencies:
Polly,Serilog,Franz.Common.Mediator
- Part of the private Franz Framework ecosystem.
β¨ Features
π Retry Pipeline β automatic retries with backoff & correlated telemetry.
π¦ Circuit Breaker Pipeline β prevents cascading failures under load.
π Advanced Circuit Breaker Pipeline β trips based on failure ratio in rolling window.
β± Timeout Pipeline β cancels long-running requests automatically.
π¦ Bulkhead Pipeline β limits concurrent requests and queue pressure.
π§ ResilienceContext β shared state across all resilience pipelines:
RetryCount,CircuitOpen,TimeoutOccurred,BulkheadRejected,Duration
π IResilienceObserver β extensibility hooks for external telemetry, alerts, or dashboards.
π Enriched Serilog Logging β all logs include:
- Correlation ID
- Request type
- Policy name
- Pipeline name
- Execution time
- Health indicators
π¦ Installation
dotnet add package Franz.Common.Mediator.Polly
βοΈ Setup
1. Config-driven Entry Point (v1.6.2+)
From v1.6.2, resilience is now config-driven.
Define your policies in appsettings.json:
"Resilience": {
"RetryPolicy": {
"Enabled": true,
"RetryCount": 3,
"RetryIntervalMilliseconds": 500
},
"CircuitBreaker": {
"Enabled": true,
"FailureThreshold": 0.5,
"MinimumThroughput": 10,
"DurationOfBreakSeconds": 30
},
"TimeoutPolicy": {
"Enabled": true,
"TimeoutSeconds": 5
},
"BulkheadPolicy": {
"Enabled": true,
"MaxParallelization": 10,
"MaxQueueSize": 20
}
}
Then just call:
builder.Services.AddFranzResilience(builder.Configuration);
β
Thatβs it β retry, circuit breaker, timeout, and bulkhead are auto-registered from config and wired into Mediator pipelines.
β
Each policy injects structured logs and updates the ResilienceContext.
2. Manual Registration (pre-1.6.2 style)
If you prefer explicit registration:
using Franz.Common.Mediator.Polly;
builder.Services.AddFranzPollyPolicies(options =>
{
options.AddRetry("DefaultRetry", retryCount: 3, intervalMs: 500);
options.AddCircuitBreaker("DefaultCircuitBreaker", 0.5, 10, 30);
options.AddTimeout("DefaultTimeout", 5);
options.AddBulkhead("DefaultBulkhead", 10, 20);
});
builder.Services
.AddFranzPollyRetry("DefaultRetry")
.AddFranzPollyCircuitBreaker("DefaultCircuitBreaker")
.AddFranzPollyTimeout("DefaultTimeout")
.AddFranzPollyBulkhead("DefaultBulkhead");
π§ Observability Enhancements (v1.6.14)
Version 1.6.14 introduces a resilience-awareness layer across all Mediator pipelines.
π§© ResilienceContext
Carries runtime state between pipelines:
public sealed class ResilienceContext
{
public string PolicyName { get; init; } = string.Empty;
public int RetryCount { get; set; }
public bool CircuitOpen { get; set; }
public bool TimeoutOccurred { get; set; }
public bool BulkheadRejected { get; set; }
public TimeSpan Duration { get; set; }
public DateTimeOffset Timestamp { get; } = DateTimeOffset.UtcNow;
public bool IsHealthy => !CircuitOpen && !TimeoutOccurred && !BulkheadRejected;
}
Each pipeline updates this context and emits structured logs through Serilog.
π IResilienceObserver
Observers can listen to policy outcomes globally:
public interface IResilienceObserver
{
void OnPolicyExecuted(string policyName, ResilienceContext context);
}
You can implement custom observers for metrics or telemetry (e.g., Application Insights, Prometheus, Elastic APM).
Example:
public sealed class ElasticResilienceObserver : IResilienceObserver
{
private readonly ILogger<ElasticResilienceObserver> _logger;
public ElasticResilienceObserver(ILogger<ElasticResilienceObserver> logger)
=> _logger = logger;
public void OnPolicyExecuted(string policyName, ResilienceContext context)
=> _logger.LogInformation("π§ {Policy} -> Healthy={Healthy} Duration={Duration}ms Retries={RetryCount}",
policyName, context.IsHealthy, context.Duration.TotalMilliseconds, context.RetryCount);
}
Register it once:
builder.Services.AddSingleton<IResilienceObserver, ElasticResilienceObserver>();
π Pipelines Overview
| Pipeline | Options Class | Key | Observes Context |
|---|---|---|---|
| Retry | PollyRetryPipelineOptions |
"RetryPolicy" |
β |
| Circuit Breaker | PollyCircuitBreakerPipelineOptions |
"CircuitBreaker" |
β |
| Advanced Circuit Breaker | PollyAdvancedCircuitBreakerOptions |
"AdvancedCircuitBreaker" |
β |
| Timeout | PollyTimeoutPipelineOptions |
"TimeoutPolicy" |
β |
| Bulkhead | PollyBulkheadPipelineOptions |
"BulkheadPolicy" |
β |
All pipelines automatically participate in Franzβs logging & correlation system.
π§© Example Logs (v1.6.14)
Success
[12:01:22 INF] βΆοΈ Executing GetBookQuery [abc123] with RetryPolicy
[12:01:22 INF] β
GetBookQuery [abc123] succeeded after 47ms (policy RetryPolicy, retries=0)
Retry + Timeout
[12:01:25 WRN] π GetBookQuery [abc123] retry attempt 2 (policy RetryPolicy)
[12:01:25 ERR] β±οΈ GetBookQuery [abc123] timed out after 5s (policy TimeoutPolicy)
Circuit Breaker Open
[12:01:27 ERR] β GetBookQuery [abc123] failed after 3 retries (policy RetryPolicy)
[12:01:27 WRN] π¦ Circuit opened for 30s (policy CircuitBreaker)
π Benefits
- π§© Composability-first β pipelines remain orthogonal yet share context.
- π§ Self-aware architecture β logs know what policies were triggered.
- π Observer hooks β tap into resilience events for monitoring or dashboards.
- β‘ Zero boilerplate β configured in <20 lines.
- π’ Enterprise-ready β deterministic, auditable, and DI-safe.
πΊ Roadmap
-
FranzResilienceSummaryPipelineβ emits aggregated resilience telemetry per request. - OpenTelemetry integration via Activity tags.
- Prebuilt βDefaultSetsβ (HTTP, Database, Messaging).
π Changelog
v1.6.14
- π§ Introduced
ResilienceContextβ unified runtime state for all pipelines. - π Added
IResilienceObserverfor external resilience monitoring. - π§Ύ Upgraded all pipelines to emit context-rich Serilog logs.
- π Added correlation ID propagation across all resilience policies.
- π Internal optimizations to reduce policy lookup overhead.
v1.6.2
- β¨ Added
AddFranzResilience(IConfiguration)for config-driven resilience. - β»οΈ Unified policy registry and Mediator pipelines.
- π‘ Simplified startup β <20 lines bootstraps resilience + mediator.
v2.0.1 β Internal Modernization
- Messaging and infrastructure refactored for async, thread-safety, and modern .NET 10 patterns.
- All APIs remain fully backward compatible.
- Tests, listeners, and pipeline components modernized.
β‘ With Franz.Common.Mediator.Polly, resilience is first-class, observable, and deterministic.
Configure it once β and your Mediator pipelines automatically enforce retries, timeouts, bulkheads, and breakers with total visibility.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Franz.Common.Mediator (>= 2.0.2)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.5)
- Polly (>= 8.6.6)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Franz.Common.Mediator.Polly:
| Package | Downloads |
|---|---|
|
Franz.Common.Messaging.AzureEventBus
Shared utility library for the Franz Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.2 | 94 | 3/30/2026 |
| 2.0.1 | 97 | 3/29/2026 |
| 1.7.8 | 104 | 3/2/2026 |
| 1.7.7 | 120 | 1/31/2026 |
| 1.7.6 | 124 | 1/22/2026 |
| 1.7.5 | 117 | 1/10/2026 |
| 1.7.4 | 117 | 12/27/2025 |
| 1.7.3 | 197 | 12/22/2025 |
| 1.7.2 | 207 | 12/21/2025 |
| 1.7.1 | 138 | 12/20/2025 |
| 1.7.0 | 295 | 12/16/2025 |
| 1.6.21 | 205 | 11/27/2025 |
| 1.6.20 | 214 | 11/24/2025 |
| 1.6.19 | 178 | 10/25/2025 |
| 1.6.15 | 211 | 10/20/2025 |
| 1.6.14 | 197 | 10/15/2025 |
| 1.6.3 | 204 | 10/9/2025 |
| 1.6.2 | 201 | 10/7/2025 |
| 1.5.9 | 216 | 9/24/2025 |
| 1.5.4 | 208 | 9/23/2025 |