Skip to main content

simple_queue/queue/
workers_api.rs

1#[cfg(feature = "janitor")]
2use crate::janitor;
3use crate::reaper;
4use crate::*;
5
6// Main loop
7impl SimpleQueue {
8    /// Return a [`reaper::Reaper`] instance that fixes stale jobs
9    ///
10    /// Useful when you want to control [`reaper::Reaper`] thread yourself.
11    pub async fn reaper(&self) -> reaper::Reaper {
12        let pool = self.pool.clone();
13        let heartbeat_interval = tokio::time::interval(self.heartbeat_interval);
14        reaper::Reaper {
15            pool,
16            heartbeat_interval,
17        }
18    }
19    #[cfg(feature = "janitor")]
20    pub async fn janitor(&self) -> janitor::Janitor {
21        let pool = self.pool.clone();
22        let interval = tokio::time::interval(self.janitor_interval);
23        janitor::Janitor { pool, interval }
24    }
25}