Expand description
Futures aware circuit breaker.
§Example
Using default backoff strategy and failure accrual policy.
use failsafe::Config;
use failsafe::futures::CircuitBreaker;
// A function that sometimes fails.
async fn dangerous_call() -> Result<(), ()> {
if thread_rng().gen_range(0..2) == 0 {
return Err(())
}
Ok(())
}
// Create a circuit breaker which configured by reasonable default backoff and
// failure accrual policy.
let circuit_breaker = Config::new().build();
// Wraps `dangerous_call` result future within circuit breaker.
let future = circuit_breaker.call(dangerous_call());
let result = future.await;
Modules§
- calls CircuitBreaker in a Stream that can be polled with
next()
Structs§
- A circuit breaker’s future.
Traits§
- A futures aware circuit breaker’s public interface.