sift_stream/stream/retry.rs
1use std::time::Duration;
2
3/// A retry policy that is used to configure the retry behavior of a Sift stream. Most users should
4/// opt to use the default retry policy provided by [RetryPolicy::default], however, they are able
5/// to completely configure their own.
6#[derive(Debug, Clone)]
7pub struct RetryPolicy {
8 pub max_attempts: u8,
9 pub initial_backoff: Duration,
10 pub max_backoff: Duration,
11 pub backoff_multiplier: u8,
12}
13
14impl Default for RetryPolicy {
15 /// The default [RetryPolicy] that is configured to retry 5 times with exponential backoff.
16 fn default() -> Self {
17 Self {
18 max_attempts: 5,
19 initial_backoff: Duration::from_millis(50),
20 max_backoff: Duration::from_secs(5),
21 backoff_multiplier: 5,
22 }
23 }
24}