From 8ed77d7ab484121e9d70158e14c9fd6c243f1c70 Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Mon, 12 Feb 2024 14:58:08 +0100 Subject: Close #9. Config impl with struct and files --- src/services/ping.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/services/ping.rs') diff --git a/src/services/ping.rs b/src/services/ping.rs index 7d71218..9b164c8 100644 --- a/src/services/ping.rs +++ b/src/services/ping.rs @@ -10,7 +10,7 @@ use time::{Duration, Instant}; use tokio::sync::broadcast::Sender; use tracing::{debug, error, trace}; use crate::AppState; -use crate::config::SETTINGS; +use crate::config::Config; use crate::db::Device; pub type StatusMap = DashMap; @@ -21,7 +21,7 @@ pub struct Value { pub online: bool } -pub async fn spawn(tx: Sender, device: Device, uuid: String, ping_map: &StatusMap, db: &PgPool) { +pub async fn spawn(tx: Sender, config: &Config, device: Device, uuid: String, ping_map: &StatusMap, db: &PgPool) { let timer = Instant::now(); let payload = [0; 8]; @@ -40,7 +40,7 @@ pub async fn spawn(tx: Sender, device: Device, uuid: String, error!("{}", ping.to_string()); msg = Some(BroadcastCommands::Error(uuid.clone())); } - if timer.elapsed() >= Duration::minutes(SETTINGS.get_int("pingtimeout").unwrap_or(10)) { + if timer.elapsed() >= Duration::minutes(config.pingtimeout) { msg = Some(BroadcastCommands::Timeout(uuid.clone())); } } else { -- cgit v1.2.3