Creates a new ExponentialBackoff.
the base of the exponentiation
Optional
expMax: numberthe maximum exponent, no bound if undefined
Private
_retriesPrivate
Readonly
basePrivate
Optional
Readonly
expPrivate
iCurrent number in the series.
The number of retries. Starts at 0, increases by 1 for each call to next(). Resets to 0 when reset() is called.
Generated using TypeDoc
ExponentialBackoff increases the backoff-time exponentially. An optional maximum can be provided as an upper bound to the exponent and thus to the returned backoff.
The series can be described as ('i' is the current step/retry): backoff = base * 2^i | without bound backoff = base * 2^min(i, expMax) | with bound
Example:
Without bound: base = 1000, expMax = undefined backoff = 1000 * 2^0 = 1000 // first retry backoff = 1000 * 2^1 = 2000 // second retry backoff = 1000 * 2^2 = 4000 // ...doubles with every retry backoff = 1000 * 2^3 = 8000 backoff = 1000 * 2^4 = 16000 ... // and so on
With bound: base = 1000, expMax = 3 backoff = 1000 * 2^0 = 1000 // first retry backoff = 1000 * 2^1 = 2000 // second retry backoff = 1000 * 2^2 = 4000 // third retry backoff = 1000 * 2^3 = 8000 // maximum reached, don't increase further backoff = 1000 * 2^3 = 8000 backoff = 1000 * 2^3 = 8000 ... // and so on