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
object
ExponentialBackOff
Implements
IBackOff
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
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 DeltaBackOff set to 250ms and MaxNumOfRetries set to 10.

Declaration
public ExponentialBackOff()

ExponentialBackOff(TimeSpan, int)

Constructs a new exponential back-off with the given delta and maximum retries. If unspecified, maximumNumOfRetries is set to 10.

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

Properties

DeltaBackOff

Time span used to bound the back-off jitter. 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 between 0.75sec and 1.25sec, 1.75sec and 2.25sec, 3.75sec and 4.25sec, and so on. Only one of DeltaBackOff and DeltaBackOffPercent may be specified. Both may be zero, in which case no jitter will be applied.

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

DeltaBackOffPercent

Percent of the current unjittered back-off used to bound the jitter. If the value is set to 10, and the current back-off is 1000ms, then the jitter will be generated from -100ms to 100ms and the jittered back-off will be from 900ms to 1100ms. Only one of DeltaBackOff and DeltaBackOffPercent may be specified. Both may be zero, in which case no jitter will be applied.

Declaration
public short DeltaBackOffPercent { get; }
Property Value
Type Description
short

MaxNumOfRetries

The maximum number of retries. Default value is 10.

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

Methods

FromDeltaBackOffPercent(short, int)

Constructs a new exponential back-off with the given delta percent and maximum retries. If unspecified, maximumNumOfRetries is set to 10.

Declaration
public static ExponentialBackOff FromDeltaBackOffPercent(short deltaBackOffPercent, int maximumNumOfRetries = 10)
Parameters
Type Name Description
short deltaBackOffPercent
int maximumNumOfRetries
Returns
Type Description
ExponentialBackOff

GetNextBackOff(int)

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.

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

Implements

IBackOff

Extension Methods

Utilities.ThrowIfNull<T>(T, string)
In this article
Back to top Generated by DocFX