circuit_breaker/global
Global circuit breaker registry via persistent_term.
Stores the circuit breaker actor in a node-wide registry so it can be retrieved from any process without passing it explicitly.
Usage
let assert Ok(cb) = actor.start(config)
global.set(cb)
// From anywhere:
global.check_and_call("my_service")
global.record_failure("my_service")
Types
pub type CircuitBreaker =
process.Subject(actor.CircuitBreakerCommand)
Values
pub fn check_and_call(key: String) -> actor.CheckResult
Check whether a call is allowed, using the global instance. Returns Allowed if no global circuit breaker is registered.
pub fn get() -> option.Option(
process.Subject(actor.CircuitBreakerCommand),
)
Retrieve the global circuit breaker actor, if alive.
pub fn record_failure(key: String) -> Nil
pub fn record_success(key: String) -> Nil
pub fn set(
cb: process.Subject(actor.CircuitBreakerCommand),
) -> Nil
Register the circuit breaker actor as the global instance.