pub struct ConsecutiveFailures { /* private fields */ }Available on crate feature
circuit-breaker only.Expand description
A CircuitPolicy that opens the circuit after N consecutive failures
and closes it again once a sufficient fraction of probes succeed.
§Parameters
| Parameter | Description |
|---|---|
failure_threshold | Number of consecutive failures needed to open the circuit. |
success_threshold | Fraction of HalfOpen probes (0.0–1.0) that must succeed to close. |
timeout | How long to stay Open before sending the first probe. |
§Example
ⓘ
use tower::circuit_breaker::{CircuitBreakerLayer, ConsecutiveFailures};
use std::time::Duration;
let policy = ConsecutiveFailures::new(5, 0.8, Duration::from_secs(30));
let layer = CircuitBreakerLayer::with_policy(policy);Implementations§
Trait Implementations§
Source§impl CircuitPolicy for ConsecutiveFailures
impl CircuitPolicy for ConsecutiveFailures
Source§fn on_success(&mut self) -> bool
fn on_success(&mut self) -> bool
Called after a successful response from the inner service. Read more
Source§fn on_failure(&mut self) -> bool
fn on_failure(&mut self) -> bool
Called after a failed response from the inner service. Read more
Source§fn on_half_open(&mut self)
fn on_half_open(&mut self)
Source§impl Clone for ConsecutiveFailures
impl Clone for ConsecutiveFailures
Source§fn clone(&self) -> ConsecutiveFailures
fn clone(&self) -> ConsecutiveFailures
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ConsecutiveFailures
impl RefUnwindSafe for ConsecutiveFailures
impl Send for ConsecutiveFailures
impl Sync for ConsecutiveFailures
impl Unpin for ConsecutiveFailures
impl UnsafeUnpin for ConsecutiveFailures
impl UnwindSafe for ConsecutiveFailures
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more