LiteRetry 0.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package LiteRetry --version 0.0.3
                    
NuGet\Install-Package LiteRetry -Version 0.0.3
                    
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="LiteRetry" Version="0.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LiteRetry" Version="0.0.3" />
                    
Directory.Packages.props
<PackageReference Include="LiteRetry" />
                    
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 LiteRetry --version 0.0.3
                    
#r "nuget: LiteRetry, 0.0.3"
                    
#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.
#addin nuget:?package=LiteRetry&version=0.0.3
                    
Install LiteRetry as a Cake Addin
#tool nuget:?package=LiteRetry&version=0.0.3
                    
Install LiteRetry as a Cake Tool

LiteRetry.Core

LiteRetry.Core is a lightweight, fluent and flexible retry utility for .NET.
It helps developers add retry logic to any asynchronous or synchronous operation with minimal setup and maximum control.


✨ Features

  • ✅ Simple and fluent API
  • 🔁 Automatic retries with configurable limits
  • ⏱️ Support for fixed or exponential backoff
  • 🎯 Conditional retry filtering
  • 📣 Hook for onRetry callback
  • ❌ Cancellation support via CancellationToken
  • 📦 RetryResult<T> with metadata (attempts, elapsed time)
  • 🧠 RetryContext for diagnostics
  • ❗ Custom RetryFailedException

📦 Installation

You can install via NuGet:

dotnet add package LiteRetry

Or via the NuGet Package Manager:

Install-Package LiteRetry

🚀 Quick Example

using LiteRetry.Core.Retry.Fluent;

var result = await RetryBuilder<string>
    .Create()
    .WithRetries(3)
    .WithDelay(500)
    .WithBackoff()
    .Filter(ex => ex is TimeoutException)
    .OnRetry(ctx => 
    {
        Console.WriteLine($"Retry {ctx.Attempt} after {ctx.Delay.TotalMilliseconds}ms");
        return Task.CompletedTask;
    })
    .RunAsync(async () => 
    {
        // Your operation
        return await GetDataFromRemote();
    });

Console.WriteLine($"Result: {result.Value} in {result.Attempts} attempts");

🔧 Basic Usage

If you prefer a static API:

var result = await RetryExecutor.ExecuteAsync(
    action: async () => await SomeOperation(),
    options: new RetryOptions
    {
        Retries = 3,
        DelayMilliseconds = 500,
        Backoff = true,
        ShouldRetry = ex => ex is HttpRequestException
    }
);

🧱 API Components

  • RetryExecutor – Static retry logic handler
  • RetryBuilder<T> – Fluent builder for retry configuration
  • RetryContext – Info about the retry state per attempt
  • RetryResult<T> – Final result including metadata
  • RetryFailedException – Exception thrown after final failure

📄 License

This project is licensed under the MIT License.


🙌 Author

Created by Javier Angosto Barjollo

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

    • No dependencies.

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.0.0 137 5/8/2025
0.0.12 135 5/5/2025
0.0.11 139 5/4/2025
0.0.10 132 5/4/2025
0.0.9 134 5/4/2025
0.0.8 106 5/4/2025
0.0.7 95 5/4/2025
0.0.6 98 5/4/2025
0.0.5 104 5/4/2025
0.0.4 98 5/4/2025
0.0.3 63 5/3/2025
0.0.2 67 5/3/2025
0.0.1 60 5/3/2025