TaskEndurer 0.1.0

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

// Install TaskEndurer as a Cake Tool
#tool nuget:?package=TaskEndurer&version=0.1.0                

Summary

Task Endurer is a library that lets you easily retry asynchronous tasks based on a given policy.

Getting started

Installation via Package Manager Console in Visual Studio:

PM> Install-Package TaskEndurer

Installation via .NET CLI:

> dotnet add <TARGET PROJECT> package TaskEndurer

Usage

The main goal of Task Endurer is to retry a task based on a given policy in a minimal fashion. The policy is defined by the RetryPolicy class, which is constructed by the RetryPolicyBuilder class.

Example

var policy = RetryPolicyBuilder().Create() // create a policy builder
    .WithMaxRetries(3) // Maximum number of retries is 3
    .WithDelay(TimeSpan.FromSeconds(1)) // Delay between retries is 1 second

The policy can then be used to build an executor: The executor can be used to execute a task. The task will be retried if it fails, based on the policy.

var executor = policy.Build(); // Build the executor based on the policy.
executor.ExecuteAsync(async () => await Task.Delay(1000)); // Execute the task using the executor.

Policy builder options

Option Description
WithMaxRetries Specified the maximum number of retries before the task will actually fail.
WithDelay Specifies the delay between retries.
WithBackoff Specifies the backoff strategy.
WithMaxDuration Specifies the maximum duration to retry.
ContinueOnException Register expected exception types, to indicate whether to continue retrying or not after the maximum duration or maximum number of retries have been reached.
WithGracefulExceptionHandling Specifies that any exceptions should be gracefully handled and not thrown after the maximum duration or maximum number of retries have been reached.

Backoff strategies

Strategy Description
Linear The base delay time is equal to the attempt count.
Exponential Increases the time between retries exponentially by the retry count.
Fibonacci The base delay time is returned as the Fibonacci number corresponding to the current attempt.
Fixed The base delay time is calculated as a fixed value.
Polynomial The base delay time is calculated as: ae where:a is the number of unsuccessful attempts that have been made, e is the exponent configured for the strategy.
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.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 1,688 3/15/2023
0.4.1 256 3/1/2023
0.4.0 247 2/28/2023
0.3.1 259 2/22/2023
0.3.0 249 2/22/2023
0.2.1 1,676 9/20/2022
0.2.0 380 9/20/2022
0.1.2 562 9/1/2022
0.1.1 368 9/1/2022
0.1.0 381 9/1/2022