pub struct RetryPolicy {
pub max_attempts: u32,
pub initial_delay: Duration,
pub backoff_multiplier: f64,
pub max_delay: Duration,
}Expand description
重试策略
Fields§
§max_attempts: u32最大重试次数
initial_delay: Duration初始延迟
backoff_multiplier: f64延迟倍数(指数退避)
max_delay: Duration最大延迟
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn initial_delay(self, delay: Duration) -> Self
pub fn initial_delay(self, delay: Duration) -> Self
设置初始延迟
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
计算第 n 次重试的延迟
Sourcepub fn should_retry(&self, attempt: u32, error: &Error) -> bool
pub fn should_retry(&self, attempt: u32, error: &Error) -> bool
检查是否应该重试
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
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 RetryPolicy
impl Debug for RetryPolicy
Auto Trait Implementations§
impl Freeze for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin for RetryPolicy
impl UnwindSafe for RetryPolicy
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