generated from recmo/rust-service-template
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #832 from worldcoin/piohei/change_queue_monitor
Change monitor task.
- Loading branch information
Showing
1 changed file
with
12 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |