Incendium.RetryPolicy 1.0.4

dotnet add package Incendium.RetryPolicy --version 1.0.4                
NuGet\Install-Package Incendium.RetryPolicy -Version 1.0.4                
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="Incendium.RetryPolicy" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Incendium.RetryPolicy --version 1.0.4                
#r "nuget: Incendium.RetryPolicy, 1.0.4"                
#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.
// Install Incendium.RetryPolicy as a Cake Addin
#addin nuget:?package=Incendium.RetryPolicy&version=1.0.4

// Install Incendium.RetryPolicy as a Cake Tool
#tool nuget:?package=Incendium.RetryPolicy&version=1.0.4                

Incendium.RetryPolicy

License: MIT NuGet Version NuGet Downloads

Incendium.RetryPolicy is a lightweight .NET standard 2.1 library that provides robust HTTP request retry functionality and rate limiting capabilities through two main components:

  • RetryHttpClientHandler: Handles automatic retry of failed HTTP requests
  • RateGate: Manages rate limiting for your API calls

Installation

Using Package Manager:

PM> Install-Package Incendium.RetryPolicy

Using .NET CLI:

dotnet add package Incendium.RetryPolicy

Usage

RetryHttpClientHandler

The handler automatically retries requests in the following scenarios:

  • Network exceptions (HttpRequestException)
  • Server errors (5xx status codes)
  • Request timeout (408)
  • Rate limit exceeded (429)

Basic setup:

var handler = new RetryHttpClientHandler(new HttpClientHandler())
{
    RetryCount = 5, // sets 5 retry attempts
    RetryOnHttpRequestException = true, // sets the retry flag in case of an HttpRequestException
    FirstRetryDelay = TimeSpan.FromMilliseconds(100), // sets the median starting delay between requests
}
var client = new HttpClient(handler);

Rate Limiting

Integrate rate limiting using RateGate:

var handler = new RetryHttpClientHandler(new HttpClientHandler())
{
    RateGate = new RateGate(
        occurrences: 10,    // Maximum requests
        timeUnit: TimeSpan.FromSeconds(60)    // Time window
    )
};

Retry Delay Strategies

The library provides three built-in delay strategies:

  1. Constant Delay
handler.RetryDelaysFactory = () => Delays.Constant(
    delay: TimeSpan.FromSeconds(1),
    count: 5
);
  1. Exponential Backoff
handler.RetryDelaysFactory = () => Delays.Exponential(
    firstDelay: TimeSpan.FromMilliseconds(100),
    count: 5
);
  1. DecorrelatedJitterBackoffV2 (Default)
handler.RetryDelaysFactory = () => Delays.DecorrelatedJitterBackoffV2(
    firstDelay: TimeSpan.FromMilliseconds(100),
    count: 5
);

You can also implement custom delay strategies by providing your own IEnumerable<TimeSpan> through the RetryDelaysFactory property.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Incendium.RetryPolicy:

Package Downloads
Revelium.Evm

Revelium.Evm is .NET integration library for Etherlink and EVM-compatible networks

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 323 1/29/2025
1.0.3 42 1/29/2025
1.0.2 247 8/15/2024
1.0.1 118 8/12/2024
1.0.0 125 8/12/2024