pub struct TimeBasedPolicy { /* private fields */ }Expand description
Time-based policy that considers time windows for decisions.
Implementations§
Source§impl TimeBasedPolicy
impl TimeBasedPolicy
Sourcepub fn new(
window_size: Duration,
bucket_count: usize,
failure_threshold: f64,
min_call_count: u64,
min_recovery_time: Duration,
consecutive_successes_threshold: u64,
) -> Self
pub fn new( window_size: Duration, bucket_count: usize, failure_threshold: f64, min_call_count: u64, min_recovery_time: Duration, consecutive_successes_threshold: u64, ) -> Self
Creates a new time-based policy.
Sourcepub fn record_success(&self)
pub fn record_success(&self)
Records a successful call in the time window.
Sourcepub fn record_failure(&self)
pub fn record_failure(&self)
Records a failed call in the time window.
Trait Implementations§
Source§impl BreakerPolicy for TimeBasedPolicy
impl BreakerPolicy for TimeBasedPolicy
Source§fn should_trip(&self, stats: &BreakerStats) -> bool
fn should_trip(&self, stats: &BreakerStats) -> bool
Determines if the circuit should trip open based on current stats.
Source§fn should_reset(&self, stats: &BreakerStats) -> bool
fn should_reset(&self, stats: &BreakerStats) -> bool
Determines if the circuit should reset to closed based on current stats.
Auto Trait Implementations§
impl !Freeze for TimeBasedPolicy
impl !RefUnwindSafe for TimeBasedPolicy
impl Send for TimeBasedPolicy
impl Sync for TimeBasedPolicy
impl Unpin for TimeBasedPolicy
impl UnwindSafe for TimeBasedPolicy
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