exponentialDelayInOpenState
fun exponentialDelayInOpenState(initialDelay: Duration = 500L.milliseconds, multiplier: Double = 2.0, maxDelay: Duration = 1.minutes)(source)
Configures the circuit breaker delay strategy to use an exponential backoff algorithm to calculate the next delay duration between transitions from Open to HalfOpen. The algorithm is based on the formula:
(initialDelay * multiplier^(attempt - 1))
, whereattempt
is the number of times the circuit breaker is in the Open state in one cycle.
Example:
exponential(500.milliseconds, 2.0, 1.minutes)
// Delay between transitions will be as follows:
// [500ms, 1s, 2s, 4s, 8s, 16s, 32s, 1m, 1m, 1m, ...]
Content copied to clipboard
Parameters
initialDelay
the initial delay before the first transition.
multiplier
the multiplier to increase the delay between transitions.
maxDelay
the maximum delay between transitions. Used as a safety net to prevent infinite delays.