ExponentialBackoff

class ExponentialBackoff(baseTimeMillis: Long = DEFAULT_BASE_TIME_MILLIS, multiplier: Float = DEFAULT_MULTIPLIER, minimumDelayMillis: Long = DEFAULT_MINIMUM_DELAY, maximumDelayMillis: Long = DEFAULT_MAXIMUM_DELAY) : DelayStrategy

Deprecated

Use https://github.com/michaelbull/kotlin-retry instead.

DelayStrategy with an exponentially increasing delay, calculated with getExponentialBackoffMillis.

minimumDelayMillis indicates the capped minimum delay (in milliseconds). maximumDelayMillis indicates the capped maximum delay (in milliseconds).

Delay is calculated using the following formula:

delay = base * multiplier ^ iteration

For example (using base = 100 and multiplier = 2):

iterationdelay
0100
1200
2400
3800
41600
......

Inspired by: Exponential Backoff And Jitter

Constructors

Link copied to clipboard
constructor(baseTimeMillis: Long = DEFAULT_BASE_TIME_MILLIS, multiplier: Float = DEFAULT_MULTIPLIER, minimumDelayMillis: Long = DEFAULT_MINIMUM_DELAY, maximumDelayMillis: Long = DEFAULT_MAXIMUM_DELAY)

Functions

Link copied to clipboard
open suspend override fun await(iteration: Int, elapsedMillis: Long)