Expand description
Retry primitives: policy, backoff strategies, Retry-After parsing, and
the Idempotent marker trait.
§Overview
| Type / Trait | Issue | Purpose |
|---|---|---|
RetryPolicy | #112 | Max-attempt cap + backoff strategy |
BackoffStrategy | #112 | Fixed, Exponential, or DecorrelatedJitter delays |
RetryAfter | #113 | Parse Retry-After header (delta-seconds or date) |
Idempotent | #114 | Marker trait for request types safe to retry |
§Examples
use api_bones::retry::{BackoffStrategy, Idempotent, RetryPolicy};
use core::time::Duration;
struct GetUser { id: u64 }
impl Idempotent for GetUser {}
fn should_retry<R: Idempotent>(req: &R, policy: &RetryPolicy, attempt: u32) -> bool {
attempt < policy.max_attempts
}
let policy = RetryPolicy::exponential(3, Duration::from_millis(100));
let delay = policy.next_delay(1);
assert!(delay >= Duration::from_millis(100));Structs§
- Retry
After Parse Error - Error returned when a
Retry-Afterheader value cannot be parsed. - Retry
Policy - Retry policy combining a maximum-attempt cap with a
BackoffStrategy.
Enums§
- Backoff
Strategy - Backoff strategy used by
RetryPolicyto compute inter-attempt delays. - Retry
After - Parsed value of an HTTP
Retry-Afterresponse header.
Traits§
- Idempotent
- Marker trait for request types that are safe to retry.
Type Aliases§
- Retry
After Date - Inner date representation for
RetryAfter::Date.