From 79d38213da20418b78b030f7edd64bb5655dbfb1 Mon Sep 17 00:00:00 2001 From: Devdutt Shenoi Date: Tue, 11 Jun 2024 16:23:47 +0530 Subject: [PATCH] refactor: `const Duration` --- uplink/src/collector/device_shadow.rs | 5 +---- uplink/src/config.rs | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/uplink/src/collector/device_shadow.rs b/uplink/src/collector/device_shadow.rs index 6e01f0ea..2f29cad1 100644 --- a/uplink/src/collector/device_shadow.rs +++ b/uplink/src/collector/device_shadow.rs @@ -1,5 +1,3 @@ -use std::time::Duration; - use log::{error, trace}; use serde::Serialize; @@ -49,8 +47,7 @@ impl DeviceShadow { let ping_addr = "8.8.8.8".parse().unwrap(); let ping_payload = [0; 64]; - let mut device_shadow_interval = - tokio::time::interval(Duration::from_secs(self.config.interval)); + let mut device_shadow_interval = tokio::time::interval(self.config.interval); loop { _ = device_shadow_interval.tick().await; diff --git a/uplink/src/config.rs b/uplink/src/config.rs index bef2e116..8d6107c3 100644 --- a/uplink/src/config.rs +++ b/uplink/src/config.rs @@ -13,11 +13,11 @@ use crate::collector::journalctl::JournalCtlConfig; #[cfg(target_os = "android")] use crate::collector::logcat::LogcatConfig; -pub const DEFAULT_TIMEOUT: u64 = 60; +pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(60); #[inline] fn default_timeout() -> Duration { - Duration::from_secs(DEFAULT_TIMEOUT) + DEFAULT_TIMEOUT } #[inline] @@ -227,7 +227,7 @@ impl From<&ActionRoute> for ActionRoute { #[derive(Clone, Debug, Deserialize)] pub struct DeviceShadowConfig { - pub interval: u64, + pub interval: Duration, } impl Default for DeviceShadowConfig {