Skip to content

Commit 307ecfb

Browse files
committed
actually commit the queue_jobs file
1 parent 0b14587 commit 307ecfb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

site/src/queue_jobs.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use std::sync::Arc;
2+
3+
use crate::load::SiteCtxt;
4+
use parking_lot::RwLock;
5+
use tokio::time::{self, Duration};
6+
7+
/// Inserts and manages the queue at `seconds` interval
8+
pub async fn cron_enqueue_jobs(site_ctxt: Arc<RwLock<Option<Arc<SiteCtxt>>>>, seconds: u64) {
9+
let mut interval = time::interval(Duration::from_secs(seconds));
10+
11+
loop {
12+
let ctxt = site_ctxt.clone();
13+
if let Some(ctxt_clone) = {
14+
let guard = ctxt.read();
15+
guard.as_ref().cloned()
16+
} {
17+
ctxt_clone.enqueue_master_commits().await;
18+
}
19+
20+
interval.tick().await;
21+
println!("Cron job executed at: {:?}", std::time::SystemTime::now());
22+
}
23+
}

0 commit comments

Comments
 (0)