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
Content copied to clipboard
For example (using base = 100
and multiplier = 2
):
iteration | delay |
---|---|
0 | 100 |
1 | 200 |
2 | 400 |
3 | 800 |
4 | 1600 |
... | ... |
Inspired by: Exponential Backoff And Jitter