pub struct RetryConfig {
pub default_strategy: RetryStrategy,
pub enabled: bool,
pub on_retry: Option<Arc<dyn Fn(&RetryAttempt) + Send + Sync>>,
pub retry_filter: Option<Arc<dyn Fn(&LarkAPIError) -> bool + Send + Sync>>,
}Expand description
重试中间件配置
Fields§
§default_strategy: RetryStrategy全局默认重试策略
enabled: bool是否启用重试
on_retry: Option<Arc<dyn Fn(&RetryAttempt) + Send + Sync>>重试统计回调
retry_filter: Option<Arc<dyn Fn(&LarkAPIError) -> bool + Send + Sync>>自定义重试条件
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn default_strategy(self, strategy: RetryStrategy) -> Self
pub fn default_strategy(self, strategy: RetryStrategy) -> Self
设置默认重试策略
Sourcepub fn retry_filter<F>(self, filter: F) -> Self
pub fn retry_filter<F>(self, filter: F) -> Self
设置自定义重试过滤器
Sourcepub fn server_errors_only(self) -> Self
pub fn server_errors_only(self) -> Self
快速配置:仅重试服务器错误
Sourcepub fn aggressive(self) -> Self
pub fn aggressive(self) -> Self
快速配置:激进重试策略
Sourcepub fn conservative(self) -> Self
pub fn conservative(self) -> Self
快速配置:保守重试策略
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
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 RetryConfig
impl Debug for RetryConfig
Auto Trait Implementations§
impl Freeze for RetryConfig
impl !RefUnwindSafe for RetryConfig
impl Send for RetryConfig
impl Sync for RetryConfig
impl Unpin for RetryConfig
impl !UnwindSafe for RetryConfig
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