Class ExponentialBackoffRetryPolicy
An implementation of IRetryPolicy that employs an "Exponential Backoff With Jitter" strategy.
Inherited Members
Namespace: Unity.Cloud.Common
Syntax
public class ExponentialBackoffRetryPolicy : IRetryPolicy
Constructors
ExponentialBackoffRetryPolicy()
Creates a default ExponentialBackoffRetryPolicy.
Declaration
public ExponentialBackoffRetryPolicy()
ExponentialBackoffRetryPolicy(TimeSpan, TimeSpan, TimeSpan, TimeSpan)
Creates a ExponentialBackoffRetryPolicy with customized behavior.
Declaration
public ExponentialBackoffRetryPolicy(TimeSpan initialWaitTime, TimeSpan maxWaitTime, TimeSpan maxTotalWaitTime, TimeSpan maxJitter = default(TimeSpan))
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | initialWaitTime | |
| TimeSpan | maxWaitTime | |
| TimeSpan | maxTotalWaitTime | |
| TimeSpan | maxJitter |
Methods
ExecuteAsync<T>(IRetryPolicy.RetriedOperation<T>, IRetryPolicy.ShouldRetryChecker<T>, CancellationToken, IProgress<RetryQueuedProgress>)
An async method that can retry an operation if it hasn't succeeded.
Declaration
public async Task<T> ExecuteAsync<T>(IRetryPolicy.RetriedOperation<T> retriedOperation, IRetryPolicy.ShouldRetryChecker<T> shouldRetryChecker, CancellationToken cancellationToken = default(CancellationToken), IProgress<RetryQueuedProgress> progress = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IRetryPolicy.RetriedOperation<T> | retriedOperation | The IRetryPolicy.RetriedOperation<T> that needs to be performed. |
| IRetryPolicy.ShouldRetryChecker<T> | shouldRetryChecker | A IRetryPolicy.ShouldRetryChecker<T> that helps determine whether the |
| CancellationToken | cancellationToken | Token to cancel the task execution. |
| IProgress<RetryQueuedProgress> | progress | Provider for progress updates on queued retries. |
Returns
| Type | Description |
|---|---|
| Task<T> | The result of the |
Type Parameters
| Name | Description |
|---|---|
| T |
Implements
Exceptions
| Type | Condition |
|---|---|
| RetryExecutionFailedException |
|
| TimeoutException | When the retry policy expires. |
| OperationCanceledException | When the |
| InvalidArgumentException |
|