From bcc673b74bc8437071d4c46bf21a051b288273bb Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Sun, 20 Dec 2020 17:32:13 -0600 Subject: [PATCH] :recycle: refactor: extract metrics monitor function and add it to ptth_server --- crates/ptth_file_server_bin/src/main.rs | 38 +-------------- crates/ptth_server/src/file_server/metrics.rs | 47 ++++++++++++++++++- crates/ptth_server/src/lib.rs | 5 ++ 3 files changed, 52 insertions(+), 38 deletions(-) diff --git a/crates/ptth_file_server_bin/src/main.rs b/crates/ptth_file_server_bin/src/main.rs index b92d6e9..cd8f82c 100644 --- a/crates/ptth_file_server_bin/src/main.rs +++ b/crates/ptth_file_server_bin/src/main.rs @@ -100,44 +100,8 @@ async fn main () -> Result <(), anyhow::Error> { let metrics_interval = Arc::new (ArcSwap::default ()); let interval_writer = Arc::clone (&metrics_interval); - tokio::spawn (async move { - use std::time::Duration; - - use uom::si::ratio::percent; - - let mut interval = tokio::time::interval (Duration::from_secs (60)); - - let mut counter = 0_u64; - let mut next_10_time = counter; - let mut metrics_at_last_10: Arc