ExponentialBackoffDelayStrategy

class ExponentialBackoffDelayStrategy(initialDelay: Duration, factor: Double, maxDelay: Duration) : DelayStrategy(source)

Delay strategy that increases the delay duration exponentially until a max duration has been reached.

Implementation of backoff that increases the back off duration for each retry attempt. When the duration has reached the max duration, it is no longer increased.

Example: The initialDelay is 2000 ms, the factor is 1.5, and the maxDelay is 30000 ms. For 10 attempts the sequence will be as follows:

-----------------------
| attempt# | back off |
| 1 | 2000 |
| 2 | 3000 |
| 3 | 4500 |
| 4 | 6750 |
| 5 | 10125 |
| 6 | 15187 |
| 7 | 22780 |
| 8 | 30000 |
| 9 | 30000 |
| 10 | 30000 |
-----------------------

Constructors

Link copied to clipboard
constructor(initialDelay: Duration, factor: Double, maxDelay: Duration)

Functions

Link copied to clipboard
open override fun nextDelay(cause: Throwable, attempt: Long): Duration

Returns the Duration computed by this DelayStrategy to delay. Duration.ZERO means passing without delay.