ExponentialBackoffWithJitter

A DelayProvider that implements exponential backoff with jitter (i.e., randomization of delay amount). When RetryContext.errorType is non-null, the delay provider uses it to select the base delay. When RetryContext.retryAfter is non-null, it is used to clamp the computed delay. When either field is null, the provider falls back to Config.initialDelay as the base and pure exponential backoff respectively.

The delay for a given attempt is calculated as:

delay = random(1 - jitter, 1) * min(base * scaleFactor^(attempt - 1), maxBackoff)

Parameters

config

The configuration to use for this delayer.

Constructors

Link copied to clipboard
constructor(config: ExponentialBackoffWithJitter.Config = Config.Default)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open suspend override fun backoff(attempt: Int)

Delays for an appropriate amount of time after the given attempt number.