Author:
Hash:
Timestamp:
+12 -19 +/-1 browse
Kevin Schoon [me@kevinschoon.com]
c2df0a3cf7c22c251451b08be42e89ff6bc3e057
Sat, 18 Jul 2026 15:04:38 +0000 (14 hours ago)
| 1 | diff --git a/crates/database/src/subscriber.rs b/crates/database/src/subscriber.rs |
| 2 | index 6b19ef2..88f4834 100644 |
| 3 | --- a/crates/database/src/subscriber.rs |
| 4 | +++ b/crates/database/src/subscriber.rs |
| 5 | @@ -10,7 +10,9 @@ use crate::{ |
| 6 | events::{Event, Kind}, |
| 7 | }; |
| 8 | |
| 9 | - const QUICK_TIMEOUT_SECS: u64 = 120; |
| 10 | + const DEFAULT_QUICK_TIMEOUT_SECS: u64 = 120; |
| 11 | + const DEFAULT_BASE_INTERVAL_SECS: u64 = 3500; |
| 12 | + const DEFAULT_FAST_INTERVAL_SECS: u64 = 500; |
| 13 | |
| 14 | /// Name of the subscriber |
| 15 | #[derive(Copy, Clone)] |
| 16 | @@ -66,21 +68,12 @@ impl std::fmt::Display for Name { |
| 17 | pub struct Subscriber { |
| 18 | pub name: Name, |
| 19 | pub events: Vec<Kind>, |
| 20 | - #[builder(default)] |
| 21 | - pub base_interval: Duration, |
| 22 | - #[builder(default)] |
| 23 | - pub fast_interval: Duration, |
| 24 | - } |
| 25 | - |
| 26 | - impl Default for Subscriber { |
| 27 | - fn default() -> Self { |
| 28 | - Self { |
| 29 | - name: Name::AylluDispatch, |
| 30 | - events: Default::default(), |
| 31 | - base_interval: Duration::from_millis(3500), |
| 32 | - fast_interval: Duration::from_millis(500), |
| 33 | - } |
| 34 | - } |
| 35 | + #[builder(default = DEFAULT_BASE_INTERVAL_SECS)] |
| 36 | + pub base_interval: u64, |
| 37 | + #[builder(default = DEFAULT_FAST_INTERVAL_SECS)] |
| 38 | + pub fast_interval: u64, |
| 39 | + #[builder(default = DEFAULT_QUICK_TIMEOUT_SECS)] |
| 40 | + pub quick_timeout: u64, |
| 41 | } |
| 42 | |
| 43 | impl Subscriber { |
| 44 | @@ -100,13 +93,13 @@ impl Subscriber { |
| 45 | fast_time = Some(Instant::now()); |
| 46 | } |
| 47 | if let Some(duration) = fast_time { |
| 48 | - if duration.elapsed() > Duration::from_secs(QUICK_TIMEOUT_SECS) { |
| 49 | + if duration.elapsed() > Duration::from_secs(self.quick_timeout) { |
| 50 | fast_time = None |
| 51 | } |
| 52 | - std::thread::sleep(self.fast_interval); |
| 53 | + std::thread::sleep(Duration::from_secs(self.fast_interval)); |
| 54 | continue; |
| 55 | } |
| 56 | - std::thread::sleep(self.base_interval); |
| 57 | + std::thread::sleep(Duration::from_secs(self.base_interval)); |
| 58 | } |
| 59 | } |
| 60 | } |