linearDelayInOpenState

fun linearDelayInOpenState(initialDelay: Duration = 500L.milliseconds, multiplier: Double = 1.0, maxDelay: Duration = 1.minutes)(source)

Configures the circuit breaker delay strategy to use a linear backoff algorithm to calculate the next delay duration between transitions from Open to HalfOpen.

  • initialDelay + (initialDelay * (attempt - 1) * multiplier), where attempt is the number of times the circuit breaker is in the Open state in one cycle.

Example:

linear(500.milliseconds, 1.0, 4.seconds)
// Delay between transitions will be as follows:
// [500ms, 1s, 1.5s, 2s, 2.5s, 3s, 3.5s, 4s, 4s, 4s, ...]

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.

See also