pub trait JobQueue:
Send
+ Sync
+ 'static {
// Required methods
fn register<'life0, 'async_trait, T>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where T: 'async_trait + Job,
Self: 'async_trait,
'life0: 'async_trait;
fn dispatch<'life0, 'life1, 'async_trait, T>(
&'life0 self,
payload: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>
where T: 'async_trait + Job,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn pending_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = usize> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn register_with<'life0, 'async_trait, T, F, Fut>(
&'life0 self,
run: F,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where T: Job + 'async_trait,
F: Fn(T) -> Fut + Send + Sync + 'static + 'async_trait,
Fut: Future<Output = Result<(), JobError>> + Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Pluggable job-queue backend.
Required Methods§
Sourcefn register<'life0, 'async_trait, T>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
T: 'async_trait + Job,
Self: 'async_trait,
'life0: 'async_trait,
fn register<'life0, 'async_trait, T>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
T: 'async_trait + Job,
Self: 'async_trait,
'life0: 'async_trait,
Register a job type. Must be called before dispatch::<T> or start.
Sourcefn dispatch<'life0, 'life1, 'async_trait, T>(
&'life0 self,
payload: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>where
T: 'async_trait + Job,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn dispatch<'life0, 'life1, 'async_trait, T>(
&'life0 self,
payload: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<(), JobError>> + Send + 'async_trait>>where
T: 'async_trait + Job,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Enqueue a job for asynchronous execution.
Sourcefn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Spawn worker tasks. Calling start twice is a no-op; start
after Self::shutdown starts a fresh set of workers.
Sourcefn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn shutdown<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop all workers: running jobs get the shutdown grace period
(DEFAULT_SHUTDOWN_GRACE), then are aborted and handed back
to the queue. Queued jobs stay queued for the next start.
No signal reaches a running job, and an aborted one runs again from the start, so jobs are at-least-once: make them idempotent.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".