Class ExponentialBackOff (1.59.0)

public class ExponentialBackOff : IBackOff

Implementation of IBackOff that increases the back-off period for each retry attempt using a randomization function that grows exponentially. In addition, it also adds a randomize number of milliseconds for each attempt.

Inheritance

Object > ExponentialBackOff

Implements

IBackOff

Namespace

Google.Apis.Util

Assembly

Google.Apis.Core.dll

Constructors

ExponentialBackOff()

public ExponentialBackOff()

Constructs a new exponential back-off with default values.

ExponentialBackOff(TimeSpan, Int32)

public ExponentialBackOff(TimeSpan deltaBackOff, int maximumNumOfRetries = 10)

Constructs a new exponential back-off with the given delta and maximum retries.

Parameters
NameDescription
deltaBackOffTimeSpan
maximumNumOfRetriesInt32

Properties

DeltaBackOff

public TimeSpan DeltaBackOff { get; }

Gets the delta time span used to generate a random milliseconds to add to the next back-off. If the value is Zero then the generated back-off will be exactly 1, 2, 4, 8, 16, etc. seconds. A valid value is between zero and one second. The default value is 250ms, which means that the generated back-off will be [0.75-1.25]sec, [1.75-2.25]sec, [3.75-4.25]sec, and so on.

Property Value
TypeDescription
TimeSpan

MaxNumOfRetries

public int MaxNumOfRetries { get; }

Gets the maximum number of retries. Default value is 10.

Property Value
TypeDescription
Int32

Methods

GetNextBackOff(Int32)

public TimeSpan GetNextBackOff(int currentRetry)

Gets the a time span to wait before next retry. If the current retry reached the maximum number of retries, the returned value is MinValue.

Parameter
NameDescription
currentRetryInt32
Returns
TypeDescription
TimeSpan

Extension Method