Verbara.Sdk.Resilience 2.2.1

dotnet add package Verbara.Sdk.Resilience --version 2.2.1
                    
NuGet\Install-Package Verbara.Sdk.Resilience -Version 2.2.1
                    
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="Verbara.Sdk.Resilience" Version="2.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Verbara.Sdk.Resilience" Version="2.2.1" />
                    
Directory.Packages.props
<PackageReference Include="Verbara.Sdk.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 Verbara.Sdk.Resilience --version 2.2.1
                    
#r "nuget: Verbara.Sdk.Resilience, 2.2.1"
                    
#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 Verbara.Sdk.Resilience@2.2.1
                    
#: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=Verbara.Sdk.Resilience&version=2.2.1
                    
Install as a Cake Addin
#tool nuget:?package=Verbara.Sdk.Resilience&version=2.2.1
                    
Install as a Cake Tool

Verbara.Sdk.Resilience

Composable resilience primitives for .NET. AOT-safe, zero reflection, TimeProvider-based for testability. No Polly dependency. MIT licensed.

What it does

  • Circuit breaker — per-key CircuitBreakerState with classic closed → open → half-open → closed cycle. Thread-safe via Interlocked/Volatile; no locks.
  • Retry with exponential backoff — configurable maxAttempts (capped at 10) and baseDelay with ±20% deterministic jitter.
  • Per-attempt timeout — wraps action in linked CancellationTokenSource that honours both caller token and timeout.
  • Fluent builder — compose any subset of the three primitives via ResiliencePolicyBuilder and call Build().
  • First-class diagnostics via System.Diagnostics.Metrics (meter name Verbara.Sdk.Resilience): retry.attempts, circuit.opened, circuit.closed, timeout.fired, circuit.state observable gauge.

No external runtime dependencies beyond Microsoft.Extensions.* abstractions. Trim-safe.

Install

dotnet add package Verbara.Sdk.Resilience

Quick start

using Verbara.Sdk.Resilience;
using Verbara.Sdk.Resilience.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;

// 1) Register a default policy (or a no-op if configure is null).
var services = new ServiceCollection();
services.AddAsteriskResilience(b => b
    .WithCircuitBreaker(threshold: 5, openDuration: TimeSpan.FromSeconds(30))
    .WithRetry(maxAttempts: 3, baseDelay: TimeSpan.FromMilliseconds(100))
    .WithTimeout(TimeSpan.FromSeconds(5)));

// 2) Resolve + execute.
var provider = services.BuildServiceProvider();
var policy = provider.GetRequiredService<ResiliencePolicy>();

var result = await policy.ExecuteAsync(
    key: "payment-gateway",
    action: async ct =>
    {
        // Work that may throw (network call, DB write, external API, etc.).
        return await CallPaymentGatewayAsync(ct);
    },
    ct: CancellationToken.None);

Directly (without DI)

var policy = new ResiliencePolicyBuilder()
    .WithRetry(3, TimeSpan.FromMilliseconds(100))
    .WithTimeout(TimeSpan.FromSeconds(5))
    .Build();

await policy.ExecuteAsync("key", async ct => { /* work */ return 42; }, ct: default);

Observability

Meter name: Verbara.Sdk.Resilience. Enrol in OpenTelemetry:

builder.Services.AddOpenTelemetry()
    .WithMetrics(m => m.AddMeter("Verbara.Sdk.Resilience"));

Or transparently via AddAsteriskOpenTelemetry().WithAllSources().

Instruments emitted:

Instrument Kind Tags
retry.attempts Counter<long> key
circuit.opened Counter<long> key
circuit.closed Counter<long> key
timeout.fired Counter<long> key
circuit.state ObservableGauge<int> (0=closed, 1=half-open, 2=open) key

Testing

TimeProvider.System is the default clock. Inject FakeTimeProvider (Microsoft.Extensions.TimeProvider.Testing) via WithTimeProvider(fakeTimeProvider) for deterministic backoff delays and circuit open-duration testing.

License

MIT. Part of the Verbara.Sdk project.

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

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Verbara.Sdk.Resilience:

Package Downloads
Verbara.Sdk.Ami

Asterisk Manager Interface (AMI) client - actions, events, responses and protocol handling

Verbara.Sdk.Ari

Asterisk REST Interface (ARI) client - HTTP + WebSocket for Stasis applications

Verbara.Sdk.Push.Webhooks

Verbara.Sdk.Push.Webhooks - outbound HTTP webhook delivery for Verbara.Sdk.Push. Consumes events from the Push bus, matches against WebhookSubscription topic patterns, POSTs with HMAC-SHA256 signature and exponential retry/backoff. AOT-safe.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.1 354 5/23/2026
2.2.0 221 5/20/2026
2.1.2 224 5/8/2026
2.1.1 196 5/7/2026
2.1.0 192 5/7/2026
2.0.0 206 5/6/2026