Skip to content

Commit df20534

Browse files
committed
Initialize repeating jobs on queue setup.
1 parent a40d1ba commit df20534

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

deepwell/src/redis.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
*/
2020

2121
use crate::services::job::{
22-
JOB_QUEUE_DELAY, JOB_QUEUE_MAXIMUM_SIZE, JOB_QUEUE_NAME, JOB_QUEUE_PROCESS_TIME,
22+
Job, JobService, JOB_QUEUE_DELAY, JOB_QUEUE_MAXIMUM_SIZE, JOB_QUEUE_NAME,
23+
JOB_QUEUE_PROCESS_TIME,
2324
};
2425
use anyhow::Result;
2526
use redis::aio::MultiplexedConnection;
@@ -51,6 +52,17 @@ pub async fn connect(redis_uri: &str) -> Result<(MultiplexedConnection, Rsmq)> {
5152
JOB_QUEUE_MAXIMUM_SIZE,
5253
)
5354
.await?;
55+
56+
// Then add initial repeating jobs
57+
macro_rules! queue_job {
58+
($job_case:ident) => {
59+
JobService::queue_job_inner(&mut rsmq, &Job::$job_case, None).await?
60+
};
61+
}
62+
63+
queue_job!(PruneSessions);
64+
queue_job!(PrunePendingUploads);
65+
queue_job!(PruneText);
5466
}
5567

5668
Ok((connection, rsmq))

0 commit comments

Comments
 (0)