DistributedCircuitBreaker

class DistributedCircuitBreaker(store: SharedStateStore, key: String, config: CircuitBreakerConfig = CircuitBreakerConfig(), clock: Clock = Clock.System)(source)

Cross-instance circuit breaker whose state lives in a SharedStateStore: when one instance trips the breaker, every instance sharing the store fails fast. Semantics follow CircuitBreaker (Closed → Open → HalfOpen), with CircuitBreakerConfig.halfOpenMaxCalls not enforced across processes.

val breaker = DistributedCircuitBreaker(redisStore, "payments", CircuitBreakerConfig())
breaker.execute { callPayments() }

Constructors

Link copied to clipboard
constructor(store: SharedStateStore, key: String, config: CircuitBreakerConfig = CircuitBreakerConfig(), clock: Clock = Clock.System)

Functions

Link copied to clipboard

Adapts this breaker into a Policy.

Link copied to clipboard

Returns the current shared state, applying the Open → HalfOpen timeout transition.

Link copied to clipboard
suspend fun <T> execute(block: suspend () -> T): T

Runs block through the shared breaker.