-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathretry.rs
More file actions
28 lines (25 loc) · 929 Bytes
/
retry.rs
File metadata and controls
28 lines (25 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#[derive(Debug)]
pub(super) enum RetryError<E> {
Transient(E),
Permanent(E),
}
impl<E: std::fmt::Display> std::fmt::Display for RetryError<E> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
RetryError::Transient(e) => write!(f, "{e}"),
RetryError::Permanent(e) => write!(f, "{e}"),
}
}
}
impl<E: std::fmt::Display> std::error::Error for RetryError<E> where E: std::fmt::Debug {}
#[derive(Debug, Clone)]
pub struct RetryConfig {
/// * `min_delay_millis` - Initial delay before first retry attempt (in milliseconds)
pub min_delay_millis: u64,
/// * `factor` - Exponential backoff multiplier for retry delays
pub factor: f32,
/// * `max_times` - Maximum number of retry attempts
pub max_times: usize,
/// * `max_delay_seconds` - Maximum delay between retry attempts (in seconds)
pub max_delay_seconds: u64,
}