Skip to main content

Module retry

Module retry 

Source
Expand description

Retry primitives: policy, backoff strategies, Retry-After parsing, and the Idempotent marker trait.

§Overview

Type / TraitIssuePurpose
RetryPolicy#112Max-attempt cap + backoff strategy
BackoffStrategy#112Fixed, Exponential, or DecorrelatedJitter delays
RetryAfter#113Parse Retry-After header (delta-seconds or date)
Idempotent#114Marker 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§

RetryAfterParseError
Error returned when a Retry-After header value cannot be parsed.
RetryPolicy
Retry policy combining a maximum-attempt cap with a BackoffStrategy.

Enums§

BackoffStrategy
Backoff strategy used by RetryPolicy to compute inter-attempt delays.
RetryAfter
Parsed value of an HTTP Retry-After response header.

Traits§

Idempotent
Marker trait for request types that are safe to retry.

Type Aliases§

RetryAfterDate
Inner date representation for RetryAfter::Date.