summaryrefslogtreecommitdiff
path: root/src/services/ping.rs
diff options
context:
space:
mode:
authorFxQnLr <[email protected]>2024-02-12 14:58:08 +0100
committerFxQnLr <[email protected]>2024-02-12 14:58:08 +0100
commit8ed77d7ab484121e9d70158e14c9fd6c243f1c70 (patch)
treedabecfb3eaec1420782eb9d3987e54ba83612b18 /src/services/ping.rs
parente4832b4cf36ba0eaed298ee458498eddd7176590 (diff)
downloadwebol-8ed77d7ab484121e9d70158e14c9fd6c243f1c70.tar
webol-8ed77d7ab484121e9d70158e14c9fd6c243f1c70.tar.gz
webol-8ed77d7ab484121e9d70158e14c9fd6c243f1c70.zip
Close #9. Config impl with struct and files
Diffstat (limited to 'src/services/ping.rs')
-rw-r--r--src/services/ping.rs6
1 files changed, 3 insertions, 3 deletions
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};
10use tokio::sync::broadcast::Sender; 10use tokio::sync::broadcast::Sender;
11use tracing::{debug, error, trace}; 11use tracing::{debug, error, trace};
12use crate::AppState; 12use crate::AppState;
13use crate::config::SETTINGS; 13use crate::config::Config;
14use crate::db::Device; 14use crate::db::Device;
15 15
16pub type StatusMap = DashMap<String, Value>; 16pub type StatusMap = DashMap<String, Value>;
@@ -21,7 +21,7 @@ pub struct Value {
21 pub online: bool 21 pub online: bool
22} 22}
23 23
24pub async fn spawn(tx: Sender<BroadcastCommands>, device: Device, uuid: String, ping_map: &StatusMap, db: &PgPool) { 24pub async fn spawn(tx: Sender<BroadcastCommands>, config: &Config, device: Device, uuid: String, ping_map: &StatusMap, db: &PgPool) {
25 let timer = Instant::now(); 25 let timer = Instant::now();
26 let payload = [0; 8]; 26 let payload = [0; 8];
27 27
@@ -40,7 +40,7 @@ pub async fn spawn(tx: Sender<BroadcastCommands>, device: Device, uuid: String,
40 error!("{}", ping.to_string()); 40 error!("{}", ping.to_string());
41 msg = Some(BroadcastCommands::Error(uuid.clone())); 41 msg = Some(BroadcastCommands::Error(uuid.clone()));
42 } 42 }
43 if timer.elapsed() >= Duration::minutes(SETTINGS.get_int("pingtimeout").unwrap_or(10)) { 43 if timer.elapsed() >= Duration::minutes(config.pingtimeout) {
44 msg = Some(BroadcastCommands::Timeout(uuid.clone())); 44 msg = Some(BroadcastCommands::Timeout(uuid.clone()));
45 } 45 }
46 } else { 46 } else {