RetryIt is a lightweight retry helper for .NET applications. Supports async operations, exponential backoff, exception filtering, and cancellation tokens.
$ dotnet add package RetryItA lightweight, dependency-free retry helper for .NET applications.
RetryIt makes it easy to retry async operations with support for exponential backoff, exception filtering, cancellation tokens, and retry callbacks — all in a minimal API.
Task<T>)Install via NuGet:
dotnet add package RetryIt
Or via Package Manager:
Install-Package RetryIt
using RetryIt;
await Retry.ExecuteAsync(async () =>
{
await CallApiAsync();
});
await Retry.ExecuteAsync(
action: async () => await CallApiAsync(),
retries: 3,
delayMilliseconds: 500,
useExponentialBackoff: true
);
var result = await Retry.ExecuteAsync(async () =>
{
return await GetDataAsync();
});
await Retry.ExecuteAsync(
action: async () => await CallApiAsync(),
retries: 5,
shouldRetry: ex => ex is HttpRequestException
);
await Retry.ExecuteAsync(
action: async () => await CallApiAsync(),
retries: 3,
onRetry: (attempt, exception) =>
{
Console.WriteLine($"Retry {attempt}: {exception.Message}");
}
);
var cts = new CancellationTokenSource();
await Retry.ExecuteAsync(
action: async () => await CallApiAsync(),
cancellationToken: cts.Token
);
| Option | Default |
|---|---|
| Retries | 3 |
| Delay | 500 ms |
| Exponential Backoff | Disabled |
| Exception Filter | Retry all exceptions |
RetryIt is ideal for:
Unlike large resilience libraries, RetryIt focuses on:
If you need a minimal retry solution without heavy frameworks, RetryIt is for you.
MIT License