Pragmatic.Resilience 1.0.0-alpha.6

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

Pragmatic.Resilience

Native, AOT-safe resilience for .NET 10: strategy composition, a fluent builder, DI integration, and source-generator support. No Polly dependency.

The Problem

Distributed systems fail: calls time out, databases go down, APIs error. The usual fix (Polly policies or hand-rolled retry loops) scatters resilience across the codebase, pulls in external dependencies, and treats every failure the same, whether it's transient (a network blip) or permanent (a validation error).

// Without Pragmatic: manual composition, repeated at every call site
var combined = Policy.WrapAsync(
    Policy.TimeoutAsync(10),
    Policy.Handle<HttpRequestException>().CircuitBreakerAsync(5, TimeSpan.FromSeconds(30)),
    Policy.Handle<HttpRequestException>().WaitAndRetryAsync(3, a => TimeSpan.FromMilliseconds(200 * Math.Pow(2, a))));
await combined.ExecuteAsync(ct => http.PostAsJsonAsync("/charges", request, ct), ct);

The Solution

Declare a policy name; the generator composes the pipeline. One attribute, several strategies, zero manual wiring, and it distinguishes transient exceptions (retry/break) from Result failures (validation, not-found), which pass through unchanged.

[DomainAction]
[ResiliencePolicy("payment-gateway")]
public partial class ChargeCustomerAction : DomainAction<PaymentResult>
{
    public override async Task<Result<PaymentResult, IError>> Execute(CancellationToken ct)
    {
        // wrapped by the "payment-gateway" pipeline automatically:
        // retry + circuit breaker + timeout on exceptions; Result failures pass through
        var response = await _http.PostAsJsonAsync("/charges", _request, ct);
        response.EnsureSuccessStatusCode();
        return await response.Content.ReadFromJsonAsync<PaymentResult>(ct)!;
    }
}

⚠️ The name must match a configured policy. A name nobody configured, with no Resilience:Default, runs the action with no resilience at all; the generated host logs one warning per such name at startup, naming the policy and the operations that declare it. On a [Mutation] the pipeline wraps the whole invocation, save included, and each retry starts from a clean unit of work.

Installation

dotnet add package Pragmatic.Resilience

The strategies (retry with backoff and jitter, circuit breaker, timeout, hedging, fallback, rate limiter, bulkhead) compose in a defined pipeline order. Configure named policies in Program.cs or via the fluent builder. See Policies.

The declarations other modules read

Pragmatic.Resilience.Attributes also holds [Retry], [Timeout], [CircuitBreaker] and BackoffStrategy, declared here and read elsewhere. Pragmatic.Jobs and Pragmatic.Messaging each own an engine: a job retry is a lease and a durable reschedule, a message retry is a redelivery. Those stay apart. ⚠️ Only those two read them, and [CircuitBreaker] only the messaging engine: anywhere else the attribute does nothing, and the generator reports PRAG0464. On a domain action use [ResiliencePolicy]. «How many attempts, what backoff, what base delay» is one question, so it has one declaration.

[Retry(MaxAttempts = 3, Strategy = BackoffStrategy.ExponentialWithJitter, BaseDelayMs = 500)]

The attribute carries no numbers of its own. Leave a property out and the engine that reads the declaration applies its own: a job waits far longer between attempts than a redelivery does, and both are deliberate. ⚠️ Leaving a property out is not the same as setting it to 0: the first is absent from the metadata a reader sees, the second is a value you chose, and an engine may reject it (the job engine reports PRAG2504 for MaxAttempts = 0).

One declaration, one curve. Exponential waits the base delay before the first retry and doubles from there (base × 2^(n-1)), and both engines stop growing at thirty minutes rather than asking for a wait measured in days. Pinned by TheTwoRetryEnginesAgreeTests, which executes the job side and reads the message side out of the generated pipeline.

Status

Functional within 1.0.0-alpha: the strategy set, pipeline composition, DI integration, and the [ResiliencePolicy] generator. See the roadmap.

Documentation

Guide What you'll learn
Concepts Strategy model, pipeline order, transient vs permanent failures
Getting Started Declare a policy, wrap an action/call
Policies Every strategy, parameters, configuration, named policies
Common Mistakes The most frequent resilience pitfalls
Troubleshooting Problem/solution guide

Requirements

  • .NET 10.0+

License

Part of the Pragmatic.Design ecosystem. See Licensing. Pragmatic.Resilience is MIT-licensed.

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

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Pragmatic.Resilience:

Package Downloads
Pragmatic.Messaging.Core

Core messaging abstractions: IMessageBus, handlers, middleware, routing, serialization. Zero dependency on Events, EFCore, or Actions.

Pragmatic.Migrations

Declarative schema migrations for Pragmatic.Design. Diff engine, idempotent SQL generation, and migration runner. Zero EF Core dependency.

Pragmatic.Jobs

AOT-safe background job scheduling for Pragmatic.Design. Recurring (cron), delayed, and workflow jobs with SG-generated invokers.

Pragmatic.Notifications.Webhook

Webhook channel for Pragmatic.Notifications. HTTP POST delivery for admin, developer, and system notifications.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.6 242 11/21/2026
1.0.0-alpha.5 171 11/21/2026
1.0.0-alpha.4 222 11/16/2026
1.0.0-alpha.3 591 10/17/2026
1.0.0-alpha.2 204 10/12/2026
1.0.0-alpha.1 419 10/3/2026