Skip to content

amqpx v1.0.1


amqpx / index / retryStrategies / cappedExponentialBackoff

Function: cappedExponentialBackoff()

cappedExponentialBackoff(multiplier, maxDelay, base?, jitter?): (step) => number

Defined in: src/retry/time-strategies.ts:65

Increases the delay each step using the formula multiplier * base^(step-1), capped at maxDelay. Behaves identically to exponentialBackoff but clamps the result to maxDelay before applying jitter. For base=2, multiplier=100, and maxDelay=500 results in the series: 100, 200, 400, 500, 500, ...

Parameters

ParameterTypeDefault valueDescription
multipliernumberundefinedMultiplier of the function, specifying the delay at the first step.
maxDelaynumberundefinedMaximum delay in ms. The raw exponential value is clamped to this before jitter is applied.
basenumber2Base of the exponential function. Default is 2, resulting in doubling the time each step.
jitternumber0.25Jitter factor in [0, 1]. Randomizes the delay within ±jitter * delay. Use 0 to disable jitter.

Returns

(step) => number

Released under the MIT License.