ExponentialBackOffWithJitter class

Implements an Exponential Backoff with Jitter retry strategy. The function to calculate the next interval is the following (x is the xth retry): F(x) = min(Cmin+ (2^(x-1)-1) * rand(C * (1 – Jd), C*(1-Ju)), Cmax)

Constructors

ExponentialBackOffWithJitter(boolean, ErrorFilter)

Initializes a new instance of the ExponentialBackOffWithJitter class.

Properties

immediateFirstRetry

Boolean indicating whether the first retry should be immediate (if set to true) or after the normalParameters.c delay (if set to false).

normalParameters

Retry parameters used to calculate the delay between each retry in normal situations (ie. not throttled).

throttledParameters

Retry parameters used to calculate the delay between each retry in throttled situations.

Methods

nextRetryTimeout(number, boolean)

Computes the interval to wait before retrying at each new retry tentative.

shouldRetry(Error)

Based on the error passed as argument, determines if an error is transient and if the operation should be retried or not.

Constructor Details

ExponentialBackOffWithJitter(boolean, ErrorFilter)

Initializes a new instance of the ExponentialBackOffWithJitter class.

new ExponentialBackOffWithJitter(immediateFirstRetry?: boolean, errorFilter?: ErrorFilter)

Parameters

immediateFirstRetry
boolean

boolean indicating whether the first retry should be immediate (default) or wait the first interval (c value).

errorFilter
ErrorFilter

Property Details

immediateFirstRetry

Boolean indicating whether the first retry should be immediate (if set to true) or after the normalParameters.c delay (if set to false).

immediateFirstRetry: boolean

Property Value

boolean

normalParameters

Retry parameters used to calculate the delay between each retry in normal situations (ie. not throttled).

normalParameters: ExponentialBackoffWithJitterParameters

Property Value

throttledParameters

Retry parameters used to calculate the delay between each retry in throttled situations.

throttledParameters: ExponentialBackoffWithJitterParameters

Property Value

Method Details

nextRetryTimeout(number, boolean)

Computes the interval to wait before retrying at each new retry tentative.

function nextRetryTimeout(retryCount: number, isThrottled: boolean)

Parameters

retryCount
number

Current retry tentative.

isThrottled
boolean

Boolean indicating whether the Azure IoT hub is throttling operations.

Returns

number

shouldRetry(Error)

Based on the error passed as argument, determines if an error is transient and if the operation should be retried or not.

function shouldRetry(error: Error)

Parameters

error
Error

The error encountered by the operation.

Returns

boolean