Implements exponential backoff and jitter. This class tracks successful connections and failures and produces a retry delay.

It does not start any timers or directly control a connection.

The backoff follows an exponential backoff scheme with 50% jitter starting at initialRetryDelayMillis and capping at MAX_RETRY_DELAY. If RESET_INTERVAL has elapsed after a success, without an intervening faulure, then the backoff is reset to initialRetryDelayMillis.

Hierarchy

  • DefaultBackoff

Constructors

  • Parameters

    • initialRetryDelayMillis: number
    • _retryResetIntervalMillis: number
    • Optional _random: (() => number)
      Optional
        • (): number
        • Returns number

    Returns DefaultBackoff

Properties

_activeSince?: any
_backoff: any
_initialRetryDelayMillis: any
_jitter: any
_maxExponent: any

The exponent at which the backoff delay will exceed the maximum. Beyond this limit the backoff can be set to the max.

_random: any
_retryCount: any
_retryResetIntervalMillis: any

Methods

  • This function should be called when a connection fails. It returns the a delay, in milliseconds, after which a reconnection attempt should be made.

    Parameters

    • Optional timeStampMs: number

      The time of the success. Used primarily for testing, when not provided the current time is used.

      Optional

    Returns number

    The delay before the next connection attempt.

  • This function should be called when a connection attempt is successful.

    Parameters

    • Optional timeStampMs: number

      The time of the success. Used primarily for testing, when not provided the current time is used.

      Optional

    Returns void

Generated using TypeDoc