We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b14587 commit 307ecfbCopy full SHA for 307ecfb
site/src/queue_jobs.rs
@@ -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