pub struct RetryPolicy {
pub max_attempts: u32,
pub base_delay: Duration,
pub jitter: bool,
}Expand description
Policy controlling how [HttpClient::post_json_with_retry] retries failed
requests.
Successive retries use exponential backoff: the delay before attempt n
(0-indexed) is base_delay × 2ⁿ. When jitter is enabled a random
fraction of the current step is added on top, which reduces thundering-herd
bursts when many senders retry simultaneously.
§Example
ⓘ
use std::time::Duration;
use hooksmith_core::RetryPolicy;
let policy = RetryPolicy {
max_attempts: 4,
base_delay: Duration::from_millis(250),
jitter: true,
};
client.post_json_with_retry(url, &payload, &policy).await?;Fields§
§max_attempts: u32Maximum total attempts (including the first try). Clamped to at least 1.
base_delay: DurationDelay before the first retry. Each subsequent retry doubles this value.
jitter: boolWhen true, add a random sub-delay ≤ the current step to spread out
concurrent 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
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