pub struct RetryPolicy {
pub max_attempts: u32,
pub initial_backoff: Duration,
pub max_backoff: Duration,
}Expand description
Configuration for transparent retry of REST requests.
Construct via the derived RetryPolicy::builder for full control, use
RetryPolicy::conservative / RetryPolicy::aggressive for typical
presets, or keep RetryPolicy::new for the legacy positional form. Pass
to RestClient::with_retry to enable.
Fields§
§max_attempts: u32Maximum number of attempts (including the first). A value of 1
disables retry behaviour.
initial_backoff: DurationBase delay before the second attempt. Subsequent attempts double the
delay until max_backoff is hit.
max_backoff: DurationHard cap on the inter-attempt delay (jitter notwithstanding).
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn builder() -> RetryPolicyBuilder
pub fn builder() -> RetryPolicyBuilder
Create an instance of RetryPolicy using the builder syntax
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn new(
max_attempts: u32,
initial_backoff: Duration,
max_backoff: Duration,
) -> RetryPolicy
pub fn new( max_attempts: u32, initial_backoff: Duration, max_backoff: Duration, ) -> RetryPolicy
Build a custom policy via positional arguments.
Equivalent to the derived
RetryPolicy::builder().max_attempts(..).initial_backoff(..).max_backoff(..).build().
Sourcepub fn conservative() -> RetryPolicy
pub fn conservative() -> RetryPolicy
Conservative preset: 3 attempts, 100 ms initial backoff, 2 s ceiling. Safe default for monitoring or critical-path REST calls.
§Stability
Stable public API. The name and tuning values may evolve in
a major release (1.0+), but they will be preserved across all
0.x releases. FFI binding test harnesses depend on them.
Sourcepub fn aggressive() -> RetryPolicy
pub fn aggressive() -> RetryPolicy
Aggressive preset: 5 attempts, 250 ms initial backoff, 10 s ceiling. Use when the upstream is known to be flaky and the caller can tolerate longer total latency.
§Stability
Stable public API. Same guarantees as
RetryPolicy::conservative — preserved across 0.x.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more