Neuro.AppToolkit.Resilience 0.1.0-preview.2

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

Neuro.AppToolkit.Resilience

Keeps app code working when the network, a server or the device misbehaves. It works in any .NET 10 app, has no package dependencies, and is trim and AOT safe. MAUI apps add Neuro.AppToolkit.Resilience.Maui to feed in connectivity and the app lifecycle.

The package has four parts:

Part What it gives you
Pipelines Timeout, retry, circuit breaker, concurrency gate and fallback, composed into one pipeline. Plus an HttpClient handler and three presets.
Coordination KeyedAsyncLock, SingleFlight, Debouncer and Throttler.
Tasks TaskObserver (.Tasks namespace), which runs work and publishes immutable snapshots of its state.
App awareness Network and lifecycle signals, and ConnectionSupervisor (.Connections namespace) for long-lived connections.

A first pipeline

using Neuro.AppToolkit.Resilience;

ResiliencePipeline Pipeline = new ResiliencePipelineBuilder()
    .AddTimeout(TimeSpan.FromSeconds(30))
    .AddRetry(new RetryOptions
    {
        MaxAttempts = 4,
        Backoff = Backoff.DecorrelatedJitter(TimeSpan.FromMilliseconds(200)),
        MaxDelay = TimeSpan.FromSeconds(10),
        WaitForNetwork = true,
    })
    .AddCircuitBreaker(ResiliencePipelineRegistry.Default.GetOrAddCircuitBreaker("content-api"))
    .AddTimeout(TimeSpan.FromSeconds(10))
    .Build();

byte[] Bytes = await Pipeline.ExecuteAsync(
    async Token => await Http.GetByteArrayAsync(Url, Token),
    CancellationToken);

The first strategy added is the outermost one. Here a 30-second budget covers every attempt, and each attempt gets 10 seconds. When the success path runs through a pipeline it allocates nothing.

Or start from a preset: ResiliencePresets.Interactive, ResiliencePresets.Network or ResiliencePresets.Background.

HTTP

HttpClient Http = new(new ResilientHttpHandler { InnerHandler = new HttpClientHandler() });

The handler retries transient failures (408, 429, 500, 502, 503, 504 and connection errors) and honors Retry-After. Requests that are not idempotent, such as POST, are only retried when they opt in with ResilientHttpHandler.AllowRetryOption.

Telemetry

Every strategy reports to System.Diagnostics.Metrics and ActivitySource under the name Neuro.AppToolkit.Resilience, and to the optional IResilienceListener of its ResilienceEnvironment for logging.

Testing

Everything takes its clock, jitter and signals from a ResilienceEnvironment, so a test passes new ResilienceEnvironment { TimeProvider = FakeTime } and runs in fake time. The Neuro.AppToolkit.Resilience.Testing package has FakeNetworkStatus and FakeAppLifecycle; for fixed jitter, pass a Random subclass.

See the full guide.

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.
  • net10.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Neuro.AppToolkit.Resilience:

Package Downloads
Neuro.AppToolkit.Mvvm

MVVM building blocks for any .NET app, starting with BindableTask: a bindable, command-ready view of a Neuro.AppToolkit.Resilience TaskObserver.

Neuro.AppToolkit.Resilience.Testing

Test doubles for Neuro.AppToolkit.Resilience: network and app lifecycle signals that tests switch by hand.

Neuro.AppToolkit.Resilience.Maui

.NET MAUI connectivity and app lifecycle adapters for Neuro.AppToolkit.Resilience.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-preview.2 97 10/28/2026