systemprompt_sync/api_client/
retry.rs1use std::time::Duration;
8
9#[derive(Debug, Clone, Copy)]
10pub struct RetryConfig {
11 pub max_attempts: u32,
12 pub initial_delay: Duration,
13 pub max_delay: Duration,
14 pub exponential_base: u32,
15}
16
17impl Default for RetryConfig {
18 fn default() -> Self {
19 Self {
20 max_attempts: 5,
21 initial_delay: Duration::from_secs(2),
22 max_delay: Duration::from_secs(30),
23 exponential_base: 2,
24 }
25 }
26}
27
28impl RetryConfig {
29 pub fn next_delay(&self, current: Duration) -> Duration {
30 current
31 .saturating_mul(self.exponential_base)
32 .min(self.max_delay)
33 }
34}