Skip to content

Commit

Permalink
refactor: const Duration
Browse files Browse the repository at this point in the history
  • Loading branch information
Devdutt Shenoi committed Jun 11, 2024
1 parent fa48079 commit 79d3821
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions uplink/src/collector/device_shadow.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::time::Duration;

use log::{error, trace};
use serde::Serialize;

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions uplink/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 79d3821

Please sign in to comment.