pub struct RetryConfig { /* private fields */ }Expand description
Canonical retry configuration for messaging middleware.
Messaging retries historically retried every handler failure by default.
RetryPolicy defaults to retrying only errors marked retryable, so this
wrapper encodes the messaging-specific always-retry default explicitly.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub const fn from_policy(policy: RetryPolicy) -> Self
pub const fn from_policy(policy: RetryPolicy) -> Self
Wrap an explicit resilience retry policy.
Sourcepub fn with_max_attempts(self, n: usize) -> Self
pub fn with_max_attempts(self, n: usize) -> Self
Set the maximum number of attempts (including the first call).
Sourcepub fn with_initial_backoff(self, d: Duration) -> Self
pub fn with_initial_backoff(self, d: Duration) -> Self
Set the initial backoff delay before the first retry.
Sourcepub fn with_max_backoff(self, d: Duration) -> Self
pub fn with_max_backoff(self, d: Duration) -> Self
Set the upper bound on any single backoff delay.
Sourcepub fn with_backoff_factor(self, factor: f64) -> Self
pub fn with_backoff_factor(self, factor: f64) -> Self
Set the exponential backoff multiplication factor.
Sourcepub fn with_constant_backoff(self, backoff: ConstantBackoff) -> Self
pub fn with_constant_backoff(self, backoff: ConstantBackoff) -> Self
Use a fixed delay for every retry attempt.
Sourcepub fn with_linear_backoff(self, backoff: LinearBackoff) -> Self
pub fn with_linear_backoff(self, backoff: LinearBackoff) -> Self
Use a linearly increasing retry delay.
Sourcepub fn with_jitter(self, enabled: bool) -> Self
pub fn with_jitter(self, enabled: bool) -> Self
Enable or disable retry jitter.
Sourcepub fn with_retry_if(
self,
f: impl Fn(&AppError) -> bool + Send + Sync + 'static,
) -> Self
pub fn with_retry_if( self, f: impl Fn(&AppError) -> bool + Send + Sync + 'static, ) -> Self
Override the predicate used to decide whether an error is retried.
Sourcepub fn with_on_retry(
self,
f: impl Fn(u32, &AppError) + Send + Sync + 'static,
) -> Self
pub fn with_on_retry( self, f: impl Fn(u32, &AppError) + Send + Sync + 'static, ) -> Self
Register a callback called after each failed attempt before the next backoff sleep.
Sourcepub const fn policy(&self) -> &RetryPolicy
pub const fn policy(&self) -> &RetryPolicy
Borrow the underlying resilience policy.
Sourcepub fn into_policy(self) -> RetryPolicy
pub fn into_policy(self) -> RetryPolicy
Convert into the underlying resilience policy.
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more