Calculates the delay in milliseconds for the next retry attempt. Uses "exponential backoff with full jitter" algorithm.

https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/

The number of retry attempts made so far.

The delay in milliseconds for the next retry attempt.

Constructors

Methods

Constructors

  • Initializes a new instance of the ExponentialJitterBackoff class.

    Parameters

    • baseDelayMs: number = 250

      The base delay in milliseconds. This will be the average delay for the first retry attempt. Defaults to 250ms.

    • maxDelayMs: number = 15000

      The maximum delay in milliseconds. This will be the maximum delay for the last retry attempt. Defaults to 15000ms.

    • randomCallback: (() => number) = Math.random

      The callback to use for generating a random number between 0 and 1. Used by test only.

        • (): number
        • Returns a pseudorandom number between 0 and 1.

          Returns number

    Returns ExponentialJitterBackoff

Methods

  • Calculates the delay in milliseconds for the next retry attempt. Uses "exponential backoff with full jitter" algorithm.

    Parameters

    • retryCount: number

      The number of retry attempts made so far (i.e. 0 is the first retry attempt)

    Returns number

    The delay in milliseconds for the next retry attempt.