pub struct BackoffConfig {
pub base_delay: Duration,
pub max_delay: Duration,
pub cooldown_period: Duration,
pub max_retries: u32,
pub circuit_breaker_window: Duration,
}Expand description
Configuration for the exponential backoff strategy.
All fields have sensible defaults for a production trading system.
Fields§
§base_delay: DurationInitial delay before the first retry (default: 100ms).
max_delay: DurationMaximum delay between retries (default: 60s).
cooldown_period: DurationIf a service runs successfully for at least this long, the attempt counter resets to zero (default: 5 minutes).
max_retries: u32Maximum consecutive failures before the circuit breaker trips.
Set to 0 to disable the circuit breaker (default: 10).
circuit_breaker_window: DurationWindow within which max_retries failures trigger the circuit
breaker (default: 10 minutes). Only relevant when max_retries > 0.
Implementations§
Source§impl BackoffConfig
impl BackoffConfig
Sourcepub fn new(base_delay: Duration, max_delay: Duration) -> Self
pub fn new(base_delay: Duration, max_delay: Duration) -> Self
Create a new config with the given base and max delays.
Sourcepub fn with_cooldown(self, cooldown: Duration) -> Self
pub fn with_cooldown(self, cooldown: Duration) -> Self
Builder: set the cooldown period.
Sourcepub fn with_circuit_breaker(self, max_retries: u32, window: Duration) -> Self
pub fn with_circuit_breaker(self, max_retries: u32, window: Duration) -> Self
Builder: set the circuit breaker parameters.
Sourcepub fn without_circuit_breaker(self) -> Self
pub fn without_circuit_breaker(self) -> Self
Builder: disable the circuit breaker entirely.
Trait Implementations§
Source§impl Clone for BackoffConfig
impl Clone for BackoffConfig
Source§fn clone(&self) -> BackoffConfig
fn clone(&self) -> BackoffConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BackoffConfig
impl Debug for BackoffConfig
Auto Trait Implementations§
impl Freeze for BackoffConfig
impl RefUnwindSafe for BackoffConfig
impl Send for BackoffConfig
impl Sync for BackoffConfig
impl Unpin for BackoffConfig
impl UnsafeUnpin for BackoffConfig
impl UnwindSafe for BackoffConfig
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