diff options
author | FxQnLr <[email protected]> | 2024-06-17 10:35:06 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-06-17 10:35:06 +0200 |
commit | c6baa076dc41dd43b3888d713fcf39fa901d2cd3 (patch) | |
tree | ba345251131779e76c076d60971e4f7f066bf146 /src/services | |
parent | 04cd0aee6d000073e49b80a530a40cdb176f7f10 (diff) | |
parent | 8268b826cc45f5b2bd31b72339cc310789ab22d4 (diff) | |
download | webol-c6baa076dc41dd43b3888d713fcf39fa901d2cd3.tar webol-c6baa076dc41dd43b3888d713fcf39fa901d2cd3.tar.gz webol-c6baa076dc41dd43b3888d713fcf39fa901d2cd3.zip |
Merge pull request #37 from FxQnLr/time_update
Time update
Diffstat (limited to 'src/services')
-rw-r--r-- | src/services/ping.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/services/ping.rs b/src/services/ping.rs index 4e0ffcf..69c911f 100644 --- a/src/services/ping.rs +++ b/src/services/ping.rs | |||
@@ -2,8 +2,8 @@ use crate::config::Config; | |||
2 | use crate::storage::Device; | 2 | use crate::storage::Device; |
3 | use dashmap::DashMap; | 3 | use dashmap::DashMap; |
4 | use ipnetwork::IpNetwork; | 4 | use ipnetwork::IpNetwork; |
5 | use std::fmt::Display; | 5 | use std::{fmt::Display, time::Instant}; |
6 | use time::{Duration, Instant}; | 6 | use time::Duration; |
7 | use tokio::sync::broadcast::Sender; | 7 | use tokio::sync::broadcast::Sender; |
8 | use tracing::{debug, error, trace}; | 8 | use tracing::{debug, error, trace}; |
9 | 9 | ||
@@ -12,7 +12,7 @@ pub type StatusMap = DashMap<String, Value>; | |||
12 | #[derive(Debug, Clone)] | 12 | #[derive(Debug, Clone)] |
13 | pub struct Value { | 13 | pub struct Value { |
14 | pub ip: IpNetwork, | 14 | pub ip: IpNetwork, |
15 | pub eta: i64, | 15 | pub eta: u64, |
16 | pub online: bool, | 16 | pub online: bool, |
17 | } | 17 | } |
18 | 18 | ||
@@ -56,12 +56,12 @@ pub async fn spawn( | |||
56 | 56 | ||
57 | let _ = tx.send(msg.clone()); | 57 | let _ = tx.send(msg.clone()); |
58 | if msg.command == BroadcastCommands::Success { | 58 | if msg.command == BroadcastCommands::Success { |
59 | if timer.elapsed().whole_seconds() > config.pingthreshold { | 59 | if timer.elapsed().as_secs() > config.pingthreshold { |
60 | let newtimes = if let Some(mut oldtimes) = device.times { | 60 | let newtimes = if let Some(mut oldtimes) = device.times { |
61 | oldtimes.push(timer.elapsed().whole_seconds()); | 61 | oldtimes.push(timer.elapsed().as_secs()); |
62 | oldtimes | 62 | oldtimes |
63 | } else { | 63 | } else { |
64 | vec![timer.elapsed().whole_seconds()] | 64 | vec![timer.elapsed().as_secs()] |
65 | }; | 65 | }; |
66 | 66 | ||
67 | let updatedev = Device { | 67 | let updatedev = Device { |