diff options
author | FxQnLr <[email protected]> | 2024-02-12 14:58:08 +0100 |
---|---|---|
committer | FxQnLr <[email protected]> | 2024-02-12 14:58:08 +0100 |
commit | 8ed77d7ab484121e9d70158e14c9fd6c243f1c70 (patch) | |
tree | dabecfb3eaec1420782eb9d3987e54ba83612b18 /src/services | |
parent | e4832b4cf36ba0eaed298ee458498eddd7176590 (diff) | |
download | webol-8ed77d7ab484121e9d70158e14c9fd6c243f1c70.tar webol-8ed77d7ab484121e9d70158e14c9fd6c243f1c70.tar.gz webol-8ed77d7ab484121e9d70158e14c9fd6c243f1c70.zip |
Close #9. Config impl with struct and files
Diffstat (limited to 'src/services')
-rw-r--r-- | src/services/ping.rs | 6 |
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}; | |||
10 | use tokio::sync::broadcast::Sender; | 10 | use tokio::sync::broadcast::Sender; |
11 | use tracing::{debug, error, trace}; | 11 | use tracing::{debug, error, trace}; |
12 | use crate::AppState; | 12 | use crate::AppState; |
13 | use crate::config::SETTINGS; | 13 | use crate::config::Config; |
14 | use crate::db::Device; | 14 | use crate::db::Device; |
15 | 15 | ||
16 | pub type StatusMap = DashMap<String, Value>; | 16 | pub type StatusMap = DashMap<String, Value>; |
@@ -21,7 +21,7 @@ pub struct Value { | |||
21 | pub online: bool | 21 | pub online: bool |
22 | } | 22 | } |
23 | 23 | ||
24 | pub async fn spawn(tx: Sender<BroadcastCommands>, device: Device, uuid: String, ping_map: &StatusMap, db: &PgPool) { | 24 | pub 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 { |