invoke

operator fun invoke(resetTimeout: Duration, openingStrategy: CircuitBreaker.OpeningStrategy, exponentialBackoffFactor: Double = 1.0, maxResetTimeout: Duration = Duration.INFINITE, timeSource: TimeSource = TimeSource.Monotonic, onRejected: suspend () -> Unit = suspend { }, onClosed: suspend () -> Unit = suspend { }, onHalfOpen: suspend () -> Unit = suspend { }, onOpen: suspend () -> Unit = suspend { }): CircuitBreaker(source)

Attempts to create a CircuitBreaker.

Parameters

resetTimeout

is the timeout to wait in the Open state before attempting a close of the circuit breaker (but without the backoff factor applied).

openingStrategy

is the strategy that will decide if the circuit breaker should open after some failures. The available options are: - CircuitBreaker.OpeningStrategy.Count - CircuitBreaker.OpeningStrategy.SlidingWindow

exponentialBackoffFactor

is a factor to use for resetting the resetTimeout when in the HalfOpen state, in case the attempt to Close fails.

maxResetTimeout

is the maximum timeout the circuit breaker is allowed to use when applying the exponentialBackoffFactor.

onRejected

is a callback for signaling rejected tasks, so every time a task execution is attempted and rejected in CircuitBreaker.Open or CircuitBreaker.HalfOpen states.

onClosed

is a callback for signaling transitions to CircuitBreaker.State.Closed.

onHalfOpen

is a callback for signaling transitions to CircuitBreaker.State.HalfOpen.

onOpen

is a callback for signaling transitions to CircuitBreaker.State.Open.