pub struct RetryPolicy {
pub max_retries: u32,
pub base_delay: Duration,
pub backoff_factor: f64,
pub max_delay: Option<Duration>,
}Expand description
重试策略(供 CoreError 使用)
Fields§
§max_retries: u32最大重试次数
base_delay: Duration寏次重试基础延迟
backoff_factor: f64退避因子
max_delay: Option<Duration>最大延迟
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn exponential(max_retries: u32, base_delay: Duration) -> Self
pub fn exponential(max_retries: u32, base_delay: Duration) -> Self
创建指数退避重试策略
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
是否可重试
Sourcepub fn retry_delay(&self, attempt: u32) -> Option<Duration>
pub fn retry_delay(&self, attempt: u32) -> Option<Duration>
计算重试延迟
Sourcepub fn use_exponential_backoff(&self) -> bool
pub fn use_exponential_backoff(&self) -> bool
是否使用指数退避
Sourcepub fn max_retries(&self) -> u32
pub fn max_retries(&self) -> u32
最大重试次数(保持旧接口)
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