#[non_exhaustive]pub struct RetryPolicy {
pub max_attempts: u32,
pub base_delay: Duration,
pub max_delay: Duration,
pub max_server_delay: Duration,
}Expand description
Bounded retry policy for RetryingGateway.
There is no Default and no recommended attempt count: retry cost is
host policy, so the host states every value. The durations a fresh policy
starts from are the ones the compared references use — a 500 ms base
delay, an 8 s backoff cap and a 60 s server-delay ceiling (pi-ai).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_attempts: u32Total calls including the first; at least 1.
base_delay: DurationBackoff before the second attempt; it doubles per failed attempt.
max_delay: DurationCeiling on the wrapper’s own backoff. A server-requested delay is not
capped by this, only by RetryPolicy::max_server_delay.
max_server_delay: DurationCeiling on a server-requested delay. A longer request fails the call at once instead of waiting.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn new(max_attempts: u32) -> Self
pub fn new(max_attempts: u32) -> Self
A policy allowing max_attempts calls in total — the first included,
so new(1) never retries — starting from a 500 ms base delay, an 8 s
backoff cap and a 60 s server-delay ceiling. Values below 1 are raised
to 1.
Sourcepub fn with_base_delay(self, delay: Duration) -> Self
pub fn with_base_delay(self, delay: Duration) -> Self
Sets RetryPolicy::base_delay.
Sourcepub fn with_max_delay(self, delay: Duration) -> Self
pub fn with_max_delay(self, delay: Duration) -> Self
Sets RetryPolicy::max_delay.