CoreSystem.Resilience
2.0.0
dotnet add package CoreSystem.Resilience --version 2.0.0
NuGet\Install-Package CoreSystem.Resilience -Version 2.0.0
<PackageReference Include="CoreSystem.Resilience" Version="2.0.0" />
<PackageVersion Include="CoreSystem.Resilience" Version="2.0.0" />
<PackageReference Include="CoreSystem.Resilience" />
paket add CoreSystem.Resilience --version 2.0.0
#r "nuget: CoreSystem.Resilience, 2.0.0"
#:package CoreSystem.Resilience@2.0.0
#addin nuget:?package=CoreSystem.Resilience&version=2.0.0
#tool nuget:?package=CoreSystem.Resilience&version=2.0.0
⚡ CoreSystem.Resilience
Production-ready resilience framework for .NET 8
CoreSystem.Resilience provides a clean abstraction over resilience strategies for .NET applications. It enables applications to define named resilience pipelines while keeping application code independent from the underlying Polly implementation.
✨ Features
- ✅ Retry strategy
- ✅ Circuit Breaker strategy
- ✅ Timeout strategy
- ✅ Named resilience pipelines
- ✅ Dependency Injection integration
- ✅ Polly abstraction
- ✅ Built-in metrics
- ✅ OpenTelemetry compatible
- ✅ Configurable handled exceptions
- ✅ Strongly typed configuration
📦 Installation
dotnet add package CoreSystem.Resilience
🚀 Quick Start
Register the framework:
builder.Services.AddCoreResilience(options =>
{
options.AddPipeline(PipelineType.Redis, pipeline =>
{
pipeline.Retry = new RetryOptions
{
MaxRetryAttempts = 3
};
pipeline.Timeout = new TimeoutOptions
{
Timeout = TimeSpan.FromSeconds(2)
};
pipeline.CircuitBreaker = new CircuitBreakerOptions
{
FailureRatio = 0.5
};
});
});
Resolve a pipeline:
public sealed class RedisService(
IResiliencePipelineProvider provider)
{
private readonly IResiliencePipeline _pipeline =
provider.GetPipeline(PipelineType.Redis);
}
Execute an operation:
await _pipeline.ExecuteAsync(async ct =>
{
await redis.GetAsync(key, ct);
});
🛡 Supported Strategies
| Strategy | Description |
|---|---|
| Retry | Retries handled exceptions according to the configured retry options. |
| Circuit Breaker | Opens the circuit when the configured failure conditions are reached. |
| Timeout | Limits the execution time of an operation. |
The execution pipeline applies configured strategies in the following order:
Timeout → Retry → Circuit Breaker
Only strategies configured for a pipeline are added to its execution pipeline.
📊 Built-in Metrics
CoreSystem.Resilience publishes metrics using System.Diagnostics.Metrics.
The Core.Resilience meter is registered for OpenTelemetry integration.
| Metric | Description |
|---|---|
core.resilience.retry.attempts |
Total retry attempts executed by the retry strategy. |
core.resilience.timeout.triggered |
Total operations that exceeded the configured timeout. |
core.resilience.circuit.opened |
Total circuit breaker transitions to Open. |
core.resilience.circuit.half_opened |
Total circuit breaker transitions to Half-Open. |
core.resilience.circuit.closed |
Total circuit breaker transitions to Closed. |
core.resilience.pipeline.duration |
Execution time of the resilience pipeline. |
Register the meter with OpenTelemetry:
builder.Services
.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddMeter("Core.Resilience");
});
🏗 Architecture
Application
│
▼
IResiliencePipelineProvider
│
▼
PipelineRegistry
│
▼
IResiliencePipeline
│
├── Timeout
├── Retry
├── Circuit Breaker
│
▼
Polly ResiliencePipeline
│
▼
Protected Operation
Each configured PipelineType is registered in the pipeline registry and resolved through IResiliencePipelineProvider. The public abstraction exposes pipeline execution without requiring application code to depend directly on Polly.
📖 Documentation
The full documentation includes:
- Getting Started
- Configuration
- Retry
- Circuit Breaker
- Timeout
- Metrics
- Architecture
- Extensibility
Visit the GitHub repository for the complete documentation.
🤝 Contributing
Issues, discussions and pull requests are welcome.
📄 License
Released under the MIT 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 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
- CoreSystem.Observability.Abstractions (>= 1.0.0)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.28)
- Microsoft.Extensions.Options (>= 8.0.2)
- OpenTelemetry (>= 1.15.3)
- OpenTelemetry.Api (>= 1.15.3)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- Polly (>= 8.7.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on CoreSystem.Resilience:
| Package | Downloads |
|---|---|
|
CoreSystem.Cache
Production-ready cache abstraction for .NET 8 with In-Memory caching, extensible external storage, tag-based invalidation, HTTP response caching, and OpenTelemetry metrics. |
|
|
CoreSystem.Cache.Rehydration
Cache recovery component for CoreSystem.Cache on .NET 8 that restores tracked memory fallback entries to the primary cache provider after recovery. |
|
|
CoreSystem.Cache.Redis
Redis external cache provider for CoreSystem.Cache on .NET 8, with tag-based invalidation, distributed locking, health checks, and optional resilience integration. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Resilience pipelines with Retry, Timeout, Circuit Breaker, Dependency Injection, and OpenTelemetry metrics.