constant

fun constant(delay: Duration, randomizationFactor: Double = 0.0): DelayStrategy(source)

A delay strategy that uses a constant backoff algorithm to calculate the next delay duration. The algorithm is based on the formula:

  • delay + jitter

Example:

constant(500.milliseconds)
// Delay between attempts will be 500ms
constant(500.milliseconds, 0.1)
// Delay between attempts will be something like:
// [495ms, 513ms, 502ms, 507ms, 499ms, ...]

Note:

  • Because the jitter calculation is based on the newly calculated delay, the new delay could be less than the previous value.

Parameters

delay

The constant delay between attempts.

randomizationFactor

the randomization factor to add randomness to the calculated delay (e.g., 0.1 for +/-10%).