Trait failsafe::CircuitBreaker
source · pub trait CircuitBreaker {
// Required methods
fn is_call_permitted(&self) -> bool;
fn call_with<P, F, E, R>(&self, predicate: P, f: F) -> Result<R, Error<E>>
where P: FailurePredicate<E>,
F: FnOnce() -> Result<R, E>;
// Provided method
fn call<F, E, R>(&self, f: F) -> Result<R, Error<E>>
where F: FnOnce() -> Result<R, E> { ... }
}
Expand description
A circuit breaker’s public interface.
Required Methods§
sourcefn is_call_permitted(&self) -> bool
fn is_call_permitted(&self) -> bool
Requests permission to call.
It returns true
if a call is allowed, or false
if prohibited.
sourcefn call_with<P, F, E, R>(&self, predicate: P, f: F) -> Result<R, Error<E>>
fn call_with<P, F, E, R>(&self, predicate: P, f: F) -> Result<R, Error<E>>
Executes a given function within circuit breaker.
Depending on function result value, the call will be recorded as success or failure.
It checks error by the provided predicate. If the predicate returns true
for the
error, the call is recorded as failure otherwise considered this error as a success.
Provided Methods§
Object Safety§
This trait is not object safe.