pub struct RetryPolicy {
pub max_attempts: usize,
pub initial_delay_ms: u64,
pub max_delay_ms: u64,
pub backoff: BackoffStrategy,
pub jitter_percent: u8,
}Expand description
Configuration for retry behavior.
§Example
use converge_core::backend::{RetryPolicy, BackoffStrategy};
// Retry up to 3 times with exponential backoff starting at 100ms
let policy = RetryPolicy {
max_attempts: 3,
initial_delay_ms: 100,
max_delay_ms: 5000,
backoff: BackoffStrategy::Exponential,
jitter_percent: 20,
};
assert_eq!(policy.delay_for_attempt(1), 100); // First retry: 100ms
// Second retry: ~200ms, Third retry: ~400ms (plus jitter)Fields§
§max_attempts: usizeMaximum number of attempts (including initial attempt)
initial_delay_ms: u64Initial delay between retries in milliseconds
max_delay_ms: u64Maximum delay cap in milliseconds
backoff: BackoffStrategyBackoff strategy
jitter_percent: u8Jitter percentage (0-100) to add randomness to delays
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn aggressive() -> Self
pub fn aggressive() -> Self
Create an aggressive retry policy for critical operations.
Sourcepub fn delay_for_attempt(&self, attempt: usize) -> u64
pub fn delay_for_attempt(&self, attempt: usize) -> u64
Calculate the delay for a given attempt number (1-indexed).
Does not include jitter - caller should add jitter separately.
Sourcepub fn should_retry(&self, attempt: usize) -> bool
pub fn should_retry(&self, attempt: usize) -> bool
Check if another attempt should be made.
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 PartialEq for RetryPolicy
impl PartialEq for RetryPolicy
Source§impl Serialize for RetryPolicy
impl Serialize for RetryPolicy
impl Eq for RetryPolicy
impl StructuralPartialEq 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