pub struct RetryPolicy {
pub max_retries: u32,
pub strategy: RetryStrategy,
pub retry_on: Vec<String>,
pub dont_retry_on: Vec<String>,
pub retry_on_timeout: bool,
pub preserve_on_failure: bool,
}Expand description
Retry policy configuration
Fields§
§max_retries: u32Maximum number of retries
strategy: RetryStrategyRetry strategy
retry_on: Vec<String>Exceptions/error patterns to retry on (empty means retry all)
dont_retry_on: Vec<String>Exceptions/error patterns to not retry on
retry_on_timeout: boolWhether to retry on timeout errors
preserve_on_failure: boolWhether to preserve the original task on failure (don’t move to DLQ)
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn new(max_retries: u32, strategy: RetryStrategy) -> Self
pub fn new(max_retries: u32, strategy: RetryStrategy) -> Self
Create a new retry policy
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
Set the maximum number of retries
Sourcepub fn with_strategy(self, strategy: RetryStrategy) -> Self
pub fn with_strategy(self, strategy: RetryStrategy) -> Self
Set the retry strategy
Sourcepub fn dont_retry_on(self, patterns: Vec<String>) -> Self
pub fn dont_retry_on(self, patterns: Vec<String>) -> Self
Add error patterns to not retry on
Sourcepub fn with_retry_on_timeout(self, retry: bool) -> Self
pub fn with_retry_on_timeout(self, retry: bool) -> Self
Set whether to retry on timeout
Sourcepub fn should_retry(&self, error: &str, retry_count: u32) -> bool
pub fn should_retry(&self, error: &str, retry_count: u32) -> bool
Check if we should retry for the given error
Sourcepub fn get_retry_delay(
&self,
retry_count: u32,
previous_delay: Option<u64>,
) -> u64
pub fn get_retry_delay( &self, retry_count: u32, previous_delay: Option<u64>, ) -> u64
Get the delay before the next retry
Sourcepub const fn allows_retry(&self) -> bool
pub const fn allows_retry(&self) -> bool
Check if this policy allows retries
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
Source§impl Default for RetryPolicy
impl Default for RetryPolicy
Source§impl<'de> Deserialize<'de> for RetryPolicy
impl<'de> Deserialize<'de> for RetryPolicy
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for RetryPolicy
impl Display 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 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