pub struct CircuitBreaker {
pub threshold: u32,
pub cool_off: Duration,
pub scope: BreakerScope,
}Expand description
Holding back deliveries to a destination that keeps failing, rather than sending each one to fail in turn, as a Stoplight with its default strategies does.
After threshold failures in a row a destination’s breaker opens (red),
and deliveries to it are held — retried as failures, without a request —
until cool_off has passed since the failure that opened it. Then it is
half-open (yellow): one delivery at a time is let through as a probe,
and the others are held while it is under way. A probe that succeeds
closes the breaker; one that fails opens it for another cool_off. A
probe that never reports back stops being one after cool_off, and the
next delivery probes instead.
A failure is what may pass: a 5xx, 408, 429, or no answer. An answer that will not change is the server working. A success while the breaker is closed starts its count of failures again; one that was sent before the breaker opened and answers after does not close it, as only a probe does.
It is kept in memory, for each deliverer, unless the application gives
the deliverer a BreakerStore of its own: deliverers in several
processes sharing one store count their failures together, and let one
probe through between them.
Fields§
§threshold: u32Failures in a row that open it.
cool_off: DurationHow long it stays open before a probe is let through, and how long a probe is waited for.
scope: BreakerScopeWhat one breaker is kept for.
Trait Implementations§
Source§impl Clone for CircuitBreaker
impl Clone for CircuitBreaker
Source§fn clone(&self) -> CircuitBreaker
fn clone(&self) -> CircuitBreaker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CircuitBreaker
Source§impl Debug for CircuitBreaker
impl Debug for CircuitBreaker
Source§impl Default for CircuitBreaker
impl Default for CircuitBreaker
impl Eq for CircuitBreaker
Source§impl PartialEq for CircuitBreaker
impl PartialEq for CircuitBreaker
impl StructuralPartialEq for CircuitBreaker
Auto Trait Implementations§
impl Freeze for CircuitBreaker
impl RefUnwindSafe for CircuitBreaker
impl Send for CircuitBreaker
impl Sync for CircuitBreaker
impl Unpin for CircuitBreaker
impl UnsafeUnpin for CircuitBreaker
impl UnwindSafe for CircuitBreaker
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.