pub struct RetryConfig {
pub max_attempts: u32,
pub initial_backoff: Duration,
pub max_backoff: Duration,
}Expand description
Bounded retry configuration honouring Retry-After.
The endpoint has no idempotency key, so a retry can double-bill a request that
the server actually processed but whose response was lost to a transport error.
Set max_attempts: 1 to disable retry entirely when that risk is unacceptable.
§Examples
use jev::RetryConfig;
use std::time::Duration;
let no_retry = RetryConfig::disabled();
assert_eq!(no_retry.max_attempts, 1);
let custom = RetryConfig::default().with_max_attempts(5).with_initial_backoff(Duration::from_millis(50));
assert_eq!(custom.max_attempts, 5);Fields§
§max_attempts: u32Maximum number of attempts, including the first. 1 disables retry.
initial_backoff: DurationBackoff before the first retry.
max_backoff: DurationBackoff cap; Retry-After is clamped to this.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn with_max_attempts(self, max_attempts: u32) -> Self
pub fn with_max_attempts(self, max_attempts: u32) -> Self
Sets the maximum attempt count.
Sourcepub fn with_initial_backoff(self, backoff: Duration) -> Self
pub fn with_initial_backoff(self, backoff: Duration) -> Self
Sets the initial backoff.
Sourcepub fn with_max_backoff(self, backoff: Duration) -> Self
pub fn with_max_backoff(self, backoff: Duration) -> Self
Sets the backoff cap.
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
impl Copy for RetryConfig
Source§impl Debug for RetryConfig
impl Debug for RetryConfig
Source§impl Default for RetryConfig
impl Default for RetryConfig
Source§impl<'de> Deserialize<'de> for RetryConfigwhere
RetryConfig: Default,
impl<'de> Deserialize<'de> for RetryConfigwhere
RetryConfig: Default,
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 RetryConfig
impl PartialEq for RetryConfig
Source§impl Serialize for RetryConfig
impl Serialize for RetryConfig
impl StructuralPartialEq 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 UnsafeUnpin 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