Fluent.Unions.Polly 1.1.0

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

Fluent.Unions

Fluent.Unions.Polly

NuGet Downloads Publish Documentation

Connects Result<T> to Polly resilience strategies, so a retry can react to the error inside a result. It builds on Fluent.Unions and adds no retry logic of its own.

Installation

dotnet add package Fluent.Unions.Polly

Usage

Retry on the error in a result. HandleError reads only the result state. Cancellation is never turned into an error: it throws as usual.

using Polly;
using Polly.Retry;
using Fluent.Unions.Polly;

var pipeline = new ResiliencePipelineBuilder<Result<Payment>>()
    .AddRetry(new RetryStrategyOptions<Result<Payment>>
    {
        ShouldHandle = new PredicateBuilder<Result<Payment>>()
            .HandleError(error => error is HttpRequestException),
        MaxRetryAttempts = 3,
    })
    .Build();

Run an operation through the pipeline. A thrown exception or a cancelled token becomes an error instead of being thrown.

Result<Payment> payment = await pipeline.ExecuteResultAsync(ct => ChargeAsync(order, ct), cancellationToken);
// an Ok payment after the last attempt, or the last HttpRequestException as the error

With your own result type

Your own result type works with the same members, but HandleError<TResult, TError>() and ExecuteResultAsync<TResult, TError>(...) need explicit type arguments, because Polly's builders carry only the result type. See your own result type.

ShouldHandle = new PredicateBuilder<Result<Payment>>()
    .HandleError<Result<Payment>, DomainException>(error => error is PaymentDeclined),

Result<Payment> payment = await pipeline
    .ExecuteResultAsync<Result<Payment>, DomainException>(ct => ChargeAsync(order, ct), cancellationToken);

Convert the outcome that Polly passes to callbacks such as OnRetry.

OnRetry = args =>
{
    Result<Payment> attempt = args.Outcome.ToResult<Result<Payment>, DomainException>();
    return ValueTask.CompletedTask;
},

Documentation

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 100 11/22/2026
1.0.0 96 11/21/2026
0.3.0 99 11/20/2026
0.2.0 100 11/19/2026
0.1.0 101 11/19/2026