Class RetrySupport
This class provides the retry utility functions.
Inherited Members
Namespace: Akka.Pattern
Assembly: Akka.dll
Syntax
public static class RetrySupport
Methods
| Edit this page View SourceRetry<T>(Func<Task<T>>, int)
Given a function, returns an internally retrying Task. The first attempt will be made immediately, each subsequent attempt will be made immediately if the previous attempt failed.
If attempts are exhausted the returned Task is simply the result of invoking attempt.
Declaration
public static Task<T> Retry<T>(Func<Task<T>> attempt, int attempts)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<T>> | attempt | A function that produces the Task<TResult> to execute on each try. |
| int | attempts | Maximum number of attempts to make before giving up. |
Returns
| Type | Description |
|---|---|
| Task<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
Retry<T>(Func<Task<T>>, int, Func<int, Option<TimeSpan>>, IScheduler)
Given a function, returns an internally retrying Task. The first attempt will be made immediately, each subsequent attempt will be made after the 'delay' return by `delayFunction`(the input next attempt count start from 1). Returns None for no delay. A scheduler (eg Context.System.Scheduler) must be provided to delay each retry. You could provide a function to generate the next delay duration after first attempt, this function should never return `null`, otherwise an InvalidOperationException will be through.
If attempts are exhausted the returned Task is simply the result of invoking attempt.
Declaration
public static Task<T> Retry<T>(Func<Task<T>> attempt, int attempts, Func<int, Option<TimeSpan>> delayFunction, IScheduler scheduler)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<T>> | attempt | A function that produces the Task<TResult> to execute on each try. |
| int | attempts | Maximum number of attempts to make before giving up. |
| Func<int, Option<TimeSpan>> | delayFunction | A function that receives the next attempt number (starting from 1) and returns an Option<T> delay before that attempt. Return None for no delay. |
| IScheduler | scheduler | The scheduler instance to use. |
Returns
| Type | Description |
|---|---|
| Task<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
Retry<T>(Func<Task<T>>, int, TimeSpan, IScheduler)
Given a function, returns an internally retrying Task. The first attempt will be made immediately, each subsequent attempt will be made after 'delay'. A scheduler (eg Context.System.Scheduler) must be provided to delay each retry.
If attempts are exhausted the returned future is simply the result of invoking attempt.
Declaration
public static Task<T> Retry<T>(Func<Task<T>> attempt, int attempts, TimeSpan delay, IScheduler scheduler)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<T>> | attempt | A function that produces the Task<TResult> to execute on each try. |
| int | attempts | Maximum number of attempts to make before giving up. |
| TimeSpan | delay | The fixed duration to wait between retry attempts. |
| IScheduler | scheduler | The scheduler instance to use. |
Returns
| Type | Description |
|---|---|
| Task<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
Retry<T>(Func<Task<T>>, int, TimeSpan, TimeSpan, double, IScheduler)
Given a function, returns an internally retrying Task. The first attempt will be made immediately, each subsequent attempt will be made with a backoff time, if the previous attempt failed.
If attempts are exhausted the returned Task is simply the result of invoking attempt.
Declaration
public static Task<T> Retry<T>(Func<Task<T>> attempt, int attempts, TimeSpan minBackoff, TimeSpan maxBackoff, double randomFactor, IScheduler scheduler)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<T>> | attempt | A function that produces the Task<TResult> to execute on each try. |
| int | attempts | Maximum number of attempts to make before giving up. |
| TimeSpan | minBackoff | minimum (initial) duration until the child actor will started again, if it is terminated. |
| TimeSpan | maxBackoff | the exponential back-off is capped to this duration. |
| double | randomFactor | after calculation of the exponential back-off an additional random delay based on this factor is added, e.g. |
| IScheduler | scheduler | The scheduler instance to use. |
Returns
| Type | Description |
|---|---|
| Task<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
Edit this page