From 9ba2aaebc832ffda98c3be8673771ea7cb542d2a Mon Sep 17 00:00:00 2001 From: Ara Sadoyan Date: Tue, 29 Apr 2025 19:53:45 +0200 Subject: [PATCH] healthcheck update --- src/utils/healthcheck.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/utils/healthcheck.rs b/src/utils/healthcheck.rs index f646787..98c5f0f 100644 --- a/src/utils/healthcheck.rs +++ b/src/utils/healthcheck.rs @@ -1,6 +1,6 @@ use crate::utils::tools::*; use dashmap::DashMap; -use log::{error, warn}; +use log::{error, info, warn}; use reqwest::Client; use std::sync::atomic::AtomicUsize; use std::sync::Arc; @@ -8,8 +8,9 @@ use std::time::Duration; use tokio::time::interval; use tonic::transport::Endpoint; -pub async fn hc2(upslist: Arc, fullist: Arc, params: (&str, u64)) { +pub async fn hc2(upslist: Arc, fullist: Arc, idlist: Arc, params: (&str, u64)) { let mut period = interval(Duration::from_secs(params.1)); + let mut first_run = 0; loop { tokio::select! { _ = period.tick() => { @@ -44,9 +45,19 @@ pub async fn hc2(upslist: Arc, fullist: Arc, } totest.insert(host.clone(), inner); } + + if first_run == 1 { + info!("Synchronising inner hashmaps"); + clone_idmap_into(&totest, &idlist); + } + + first_run+=1; + if ! compare_dashmaps(&totest, &upslist){ clone_dashmap_into(&totest, &upslist); + clone_idmap_into(&totest, &idlist); } + // print!("{:?}", idlist); } } }