Show / Hide Table of Contents

Class ExponentialBackOff

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
System.Object
ExponentialBackOff
Implements
IBackOff
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Google.Apis.Util
Assembly: Google.Apis.Core.dll
Syntax
public class ExponentialBackOff : IBackOff

Constructors

ExponentialBackOff()

Constructs a new exponential back-off with default values.

Declaration
public ExponentialBackOff()

ExponentialBackOff(TimeSpan, Int32)

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

Declaration
public ExponentialBackOff(TimeSpan deltaBackOff, int maximumNumOfRetries = 10)
Parameters
Type Name Description
System.TimeSpan deltaBackOff
System.Int32 maximumNumOfRetries

Properties

DeltaBackOff

Gets the delta time span used to generate a random milliseconds to add to the next back-off. If the value is System.TimeSpan.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.

Declaration
public TimeSpan DeltaBackOff { get; }
Property Value
Type Description
System.TimeSpan

MaxNumOfRetries

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

Declaration
public int MaxNumOfRetries { get; }
Property Value
Type Description
System.Int32

Methods

GetNextBackOff(Int32)

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

Declaration
public TimeSpan GetNextBackOff(int currentRetry)
Parameters
Type Name Description
System.Int32 currentRetry
Returns
Type Description
System.TimeSpan

Implements

IBackOff

Extension Methods

Utilities.ThrowIfNull<T>(T, String)
In This Article
Back to top