pub struct ExponentialBackoffCalculator { /* private fields */ }Expand description
An exponential backoff calculator that increases the delay between retries exponentially, clamped between a minimum and maximum duration.
The backoff for attempt n is calculated as:
clamp(min * backoff_factor ^ n, min, max)§Defaults
| Parameter | Default |
|---|---|
min | 1 ms |
max | 1000 ms |
backoff_factor | 2.0 |
§Example
use couchbase_core::retrybesteffort::{BestEffortRetryStrategy, ExponentialBackoffCalculator};
use std::time::Duration;
use std::sync::Arc;
let calc = ExponentialBackoffCalculator::new(
Duration::from_millis(5), // min
Duration::from_millis(500), // max
2.0, // backoff_factor
);
let strategy = Arc::new(BestEffortRetryStrategy::new(calc));Implementations§
Trait Implementations§
Source§impl Clone for ExponentialBackoffCalculator
impl Clone for ExponentialBackoffCalculator
Source§fn clone(&self) -> ExponentialBackoffCalculator
fn clone(&self) -> ExponentialBackoffCalculator
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 moreSource§impl Debug for ExponentialBackoffCalculator
impl Debug for ExponentialBackoffCalculator
Auto Trait Implementations§
impl Freeze for ExponentialBackoffCalculator
impl RefUnwindSafe for ExponentialBackoffCalculator
impl Send for ExponentialBackoffCalculator
impl Sync for ExponentialBackoffCalculator
impl Unpin for ExponentialBackoffCalculator
impl UnsafeUnpin for ExponentialBackoffCalculator
impl UnwindSafe for ExponentialBackoffCalculator
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