From 0cf7565dff6e31dd0d1d7ad1a7adc2782ec327d9 Mon Sep 17 00:00:00 2001 From: prplV Date: Fri, 6 Jun 2025 09:00:05 -0400 Subject: [PATCH] add config delay --- .env.example | 5 ++++- crates/api-grub/Cargo.toml | 2 +- crates/api-grub/src/main.rs | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index d0cc4fe..721d0f6 100644 --- a/.env.example +++ b/.env.example @@ -30,4 +30,7 @@ ENODE_TARGET_DEVICES = "18, 19" IM_LOG_INFO = "INFO" # IM configuration for setting up API connetion # timeout (in secs). Default value - 10 -IM_CONNECTION_TIMEOUT = "10" \ No newline at end of file +IM_CONNECTION_TIMEOUT = "10" +# IM configuration for delay of requests +# delay (in secs). Default value - 5 +IM_REQUEST_DELAY = "20" \ No newline at end of file diff --git a/crates/api-grub/Cargo.toml b/crates/api-grub/Cargo.toml index bd5d13e..f171bed 100644 --- a/crates/api-grub/Cargo.toml +++ b/crates/api-grub/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "api-grub" -version = "1.0.11" +version = "1.0.15" edition = "2021" authors = ["Vladislav Drozdov "] description = "API poller for ZVKS project" diff --git a/crates/api-grub/src/main.rs b/crates/api-grub/src/main.rs index bbb05d0..49d410b 100644 --- a/crates/api-grub/src/main.rs +++ b/crates/api-grub/src/main.rs @@ -36,10 +36,16 @@ async fn main() -> Result<()>{ }, } }); + let request_delay = std::env::var("IM_REQUEST_DELAY") + .unwrap_or_else(|_| String::from("5")) + .parse::() + .unwrap_or_else(|_| { + warn!("No delay was set, setting up as 5 secs ..."); 5 + }); let event_grub = tokio::spawn(async move { // GRAB USING eNODE.MONITORING API GATEWAY if std::env::var("ENODE_MONITORING_IP").is_ok() { - match get_metrics_from_monitoring(0, 5).await { + match get_metrics_from_monitoring(0, request_delay as usize).await { Ok(_) => info!("Grabing (eNODE.Monitoring) task de-initialized"), Err(er) => error!("Grabing task returned an error : {}", er), } -- 2.40.1