arrow-fx-coroutines / arrow.fx.coroutines / CircuitBreaker

CircuitBreaker

class CircuitBreaker

Types

State The initial state when initializing a CircuitBreaker is Closed.sealed class State

Exceptions

ExecutionRejected class ExecutionRejected : Throwable

Constructors

<init> CircuitBreaker(state: AtomicRefW<State>, maxFailures: Int, resetTimeout: Duration, exponentialBackoffFactor: Double, maxResetTimeout: Duration, onRejected: suspend () -> Unit, onClosed: suspend () -> Unit, onHalfOpen: suspend () -> Unit, onOpen: suspend () -> Unit)

Functions

awaitClose Awaits for this CircuitBreaker to be CircuitBreaker.State.Closed.suspend fun awaitClose(): Unit
doOnClosed Returns a new circuit breaker that wraps the state of the source and that will fire the given callback upon the circuit breaker transitioning to the CircuitBreaker.Closed Closed state.fun doOnClosed(callback: suspend () -> Unit): CircuitBreaker
doOnHalfOpen Returns a new circuit breaker that wraps the state of the source and that will fire the given callback upon the circuit breaker transitioning to the CircuitBreaker.HalfOpen HalfOpen state.fun doOnHalfOpen(callback: suspend () -> Unit): CircuitBreaker
doOnOpen Returns a new circuit breaker that wraps the state of the source and that will fire the given callback upon the circuit breaker transitioning to the CircuitBreaker.Open Open state.fun doOnOpen(callback: suspend () -> Unit): CircuitBreaker
doOnRejectedTask Returns a new circuit breaker that wraps the state of the source and that upon a task being rejected will execute the given callback.fun doOnRejectedTask(callback: suspend () -> Unit): CircuitBreaker
protect Returns a new task that upon execution will execute the given task, but with the protection of this circuit breaker.tailrec suspend fun <A> protect(fa: suspend () -> A): A
state Returns the current CircuitBreaker.State, meant for debugging purposes.suspend fun state(): State

Companion Object Functions

of suspend fun of(maxFailures: Int, resetTimeout: Duration, exponentialBackoffFactor: Double = 1.0, maxResetTimeout: Duration = Duration.INFINITE, onRejected: suspend () -> Unit = suspend { Unit }, onClosed: suspend () -> Unit = suspend { Unit }, onHalfOpen: suspend () -> Unit = suspend { Unit }, onOpen: suspend () -> Unit = suspend { Unit }): CircuitBreaker?

Do you like Arrow?

Arrow Org
<