Skip to content

Commit

Permalink
Merge pull request #832 from worldcoin/piohei/change_queue_monitor
Browse files Browse the repository at this point in the history
Change monitor task.
  • Loading branch information
piohei authored Dec 2, 2024
2 parents a174239 + 54278fd commit 7ff3ac0
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/task_monitor/tasks/monitor_queue.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
use std::sync::Arc;

use tokio::time::{sleep, Duration};

use crate::task_monitor::{App, TaskMonitor};
use std::sync::Arc;
use tokio::time;
use tokio::time::{Duration, MissedTickBehavior};
use tracing::info;

// How often send metrics for idenity queue length
const QUEUE_MONITORING_PERIOD: Duration = Duration::from_secs(1);
// How often send metrics for identity queue length
const QUEUE_MONITORING_PERIOD: Duration = Duration::from_secs(30);

pub async fn monitor_queue(app: Arc<App>) -> anyhow::Result<()> {
let mut timer = time::interval(QUEUE_MONITORING_PERIOD);
timer.set_missed_tick_behavior(MissedTickBehavior::Skip);

loop {
timer.tick().await;
info!("Monitor queue woken due to timeout.");

TaskMonitor::log_identities_queues(&app.database).await?;
sleep(QUEUE_MONITORING_PERIOD).await;
}
}

0 comments on commit 7ff3ac0

Please sign in to comment.