app_task/backoff_strategy/
constant_time.rs1use std::time::Duration;
2
3use super::{BackoffStrategy, StrategyFactory};
4
5pub struct ContantTimeFactory {
6 pub backoff: Duration,
7}
8
9impl StrategyFactory for ContantTimeFactory {
10 type Strategy = ConstantTimeBackoff;
11
12 fn create_strategy(&self) -> Self::Strategy {
13 ConstantTimeBackoff {
14 backoff: self.backoff,
15 }
16 }
17}
18
19pub struct ConstantTimeBackoff {
20 backoff: Duration,
21}
22
23impl Default for ConstantTimeBackoff {
24 fn default() -> Self {
25 Self {
26 backoff: Duration::from_secs(5),
27 }
28 }
29}
30
31impl BackoffStrategy for ConstantTimeBackoff {
32 fn add_failure(&mut self) {}
33
34 fn next_backoff(&self) -> Duration {
35 self.backoff
36 }
37}