docs.unity3d.com
    Show / Hide Table of Contents

    Class ExponentialBackoffRetryPolicy

    An implementation of IRetryPolicy that employs an "Exponential Backoff With Jitter" strategy.

    Inheritance
    Object
    ExponentialBackoffRetryPolicy
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    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 retriedOperation should be retried.

    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 retriedOperation, if available, after shouldRetryChecker returns false.

    Type Parameters
    Name Description
    T
    Implements
    IRetryPolicy.ExecuteAsync<T>(IRetryPolicy.RetriedOperation<T>, IRetryPolicy.ShouldRetryChecker<T>, CancellationToken, IProgress<RetryQueuedProgress>)
    Exceptions
    Type Condition
    RetryExecutionFailedException
    • When shouldRetryChecker returns false after retriedOperation throws an exception, in which case the internal exception is passed through the former's innerException field.
    • When shouldRetryChecker throws an RetryExecutionFailedException, in which case this exception is immediately bubbled up.
    TimeoutException

    When the retry policy expires.

    OperationCanceledException

    When the retriedOperation or the cancellationToken is cancelled.

    InvalidArgumentException
    • When shouldRetryChecker throws an invalid exception.
    • When shouldRetryChecker does not await the completion of operationTask.

    Extension Methods

    RetryPolicyExtensions.ExecuteAsyncWithExceptionValidation(IRetryPolicy, IRetryPolicy.RetriedOperation, IRetryPolicy.ShouldRetryExceptionChecker, CancellationToken, IProgress<RetryQueuedProgress>)
    RetryPolicyExtensions.ExecuteAsyncWithExceptionValidation<T>(IRetryPolicy, IRetryPolicy.RetriedOperation<T>, IRetryPolicy.ShouldRetryExceptionChecker, CancellationToken, IProgress<RetryQueuedProgress>)
    RetryPolicyExtensions.ExecuteAsyncWithResultValidation<T>(IRetryPolicy, IRetryPolicy.RetriedOperation<T>, IRetryPolicy.ShouldRetryResultChecker<T>, CancellationToken, IProgress<RetryQueuedProgress>)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023