pub struct RetryPolicy {
pub max_retries: u32,
pub initial_delay: Duration,
pub max_delay: Duration,
pub backoff_multiplier: f64,
pub use_jitter: bool,
}Expand description
Retry policy for transient errors.
Controls exponential backoff retry behavior.
See docs/spec/interfaces/rate-limiting-retry.md
Fields§
§max_retries: u32Maximum number of retry attempts
initial_delay: DurationInitial delay before first retry
max_delay: DurationMaximum delay between retries
backoff_multiplier: f64Backoff multiplier (e.g., 2.0 for doubling)
use_jitter: boolWhether to add jitter to delays
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn new(
max_retries: u32,
initial_delay: Duration,
max_delay: Duration,
) -> Self
pub fn new( max_retries: u32, initial_delay: Duration, max_delay: Duration, ) -> Self
Create a new retry policy with custom settings.
Sourcepub fn with_jitter(self) -> Self
pub fn with_jitter(self) -> Self
Enable jitter (random variation) in retry delays.
Jitter helps prevent thundering herd problems when multiple clients retry simultaneously. Adds ±25% randomization to calculated delays.
§Examples
use github_bot_sdk::client::RetryPolicy;
let policy = RetryPolicy::default().with_jitter();Sourcepub fn without_jitter(self) -> Self
pub fn without_jitter(self) -> Self
Disable jitter (no random variation) in retry delays.
Use this for deterministic testing or when precise timing is required.
§Examples
use github_bot_sdk::client::RetryPolicy;
let policy = RetryPolicy::default().without_jitter();Sourcepub fn calculate_delay(&self, attempt: u32) -> Duration
pub fn calculate_delay(&self, attempt: u32) -> Duration
Calculate delay for a specific retry attempt.
Uses exponential backoff with optional jitter.
§Jitter
When jitter is enabled (default), applies ±25% randomization to prevent thundering herd problems. For example, a 1000ms delay becomes 750-1250ms.
§Examples
use github_bot_sdk::client::RetryPolicy;
let policy = RetryPolicy::default();
let delay = policy.calculate_delay(1);
// First retry: ~100ms ±25%See docs/spec/interfaces/rate-limiting-retry.md
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more