pub trait Queue: Send + Sync {
type JobHandle: JobHandle;
// Required methods
fn schedule_at<'life0, 'async_trait, J>(
&'life0 self,
payload: J::Payload,
scheduled_at: DateTime,
priority: i8,
) -> Pin<Box<dyn Future<Output = Result<Xid, QueueError>> + Send + 'async_trait>>
where J: JobProcessor + 'static + 'async_trait,
J::Payload: Encode,
Self: 'async_trait,
'life0: 'async_trait;
fn poll_next_with_instant<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_types: &'life1 [&'life2 str],
time: DateTime,
) -> Pin<Box<dyn Future<Output = Result<Option<Self::JobHandle>, QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn cancel_job<'life0, 'async_trait>(
&'life0 self,
job_id: Xid,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn unschedule_job<'life0, 'async_trait, J>(
&'life0 self,
job_id: Xid,
) -> Pin<Box<dyn Future<Output = Result<J::Payload, QueueError>> + Send + 'async_trait>>
where J: JobProcessor + 'static + 'async_trait,
J::Payload: Decode,
Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn schedule<'life0, 'async_trait, J>(
&'life0 self,
payload: J::Payload,
priority: i8,
) -> Pin<Box<dyn Future<Output = Result<Xid, QueueError>> + Send + 'async_trait>>
where J: JobProcessor + 'static + 'async_trait,
J::Payload: Encode,
Self: 'async_trait,
'life0: 'async_trait { ... }
fn schedule_in<'life0, 'async_trait, J>(
&'life0 self,
payload: J::Payload,
scheduled_in: Duration,
priority: i8,
) -> Pin<Box<dyn Future<Output = Result<Xid, QueueError>> + Send + 'async_trait>>
where J: JobProcessor + 'static + 'async_trait,
J::Payload: Encode,
Self: 'async_trait,
'life0: 'async_trait { ... }
fn poll_next<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_types: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Option<Self::JobHandle>, QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn next<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_types: &'life1 [&'life2 str],
interval: Duration,
) -> Pin<Box<dyn Future<Output = Result<Self::JobHandle, QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
An interface to queue implementation. Responsible for pushing jobs into the queue and pulling jobs out of the queue.
§Priority
When is enqueued one can specify priority. Jobs with higher priority will get polled first even if submitted after lower priority jobs.
Required Associated Types§
Required Methods§
Sourcefn schedule_at<'life0, 'async_trait, J>(
&'life0 self,
payload: J::Payload,
scheduled_at: DateTime,
priority: i8,
) -> Pin<Box<dyn Future<Output = Result<Xid, QueueError>> + Send + 'async_trait>>where
J: JobProcessor + 'static + 'async_trait,
J::Payload: Encode,
Self: 'async_trait,
'life0: 'async_trait,
fn schedule_at<'life0, 'async_trait, J>(
&'life0 self,
payload: J::Payload,
scheduled_at: DateTime,
priority: i8,
) -> Pin<Box<dyn Future<Output = Result<Xid, QueueError>> + Send + 'async_trait>>where
J: JobProcessor + 'static + 'async_trait,
J::Payload: Encode,
Self: 'async_trait,
'life0: 'async_trait,
Schedule a job to run at the future time.
Sourcefn poll_next_with_instant<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_types: &'life1 [&'life2 str],
time: DateTime,
) -> Pin<Box<dyn Future<Output = Result<Option<Self::JobHandle>, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn poll_next_with_instant<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_types: &'life1 [&'life2 str],
time: DateTime,
) -> Pin<Box<dyn Future<Output = Result<Option<Self::JobHandle>, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Pool queue, implementation should not wait for next job, if there nothing return Ok(None).
Sourcefn cancel_job<'life0, 'async_trait>(
&'life0 self,
job_id: Xid,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cancel_job<'life0, 'async_trait>(
&'life0 self,
job_id: Xid,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Cancel job that has been scheduled. Right now this will only cancel if the job hasn’t started yet.
Sourcefn unschedule_job<'life0, 'async_trait, J>(
&'life0 self,
job_id: Xid,
) -> Pin<Box<dyn Future<Output = Result<J::Payload, QueueError>> + Send + 'async_trait>>where
J: JobProcessor + 'static + 'async_trait,
J::Payload: Decode,
Self: 'async_trait,
'life0: 'async_trait,
fn unschedule_job<'life0, 'async_trait, J>(
&'life0 self,
job_id: Xid,
) -> Pin<Box<dyn Future<Output = Result<J::Payload, QueueError>> + Send + 'async_trait>>where
J: JobProcessor + 'static + 'async_trait,
J::Payload: Decode,
Self: 'async_trait,
'life0: 'async_trait,
The same as cancel_job, but returns payload of canceled job.
If deserialization fails, then job won’t be cancelled.
Provided Methods§
Sourcefn schedule<'life0, 'async_trait, J>(
&'life0 self,
payload: J::Payload,
priority: i8,
) -> Pin<Box<dyn Future<Output = Result<Xid, QueueError>> + Send + 'async_trait>>where
J: JobProcessor + 'static + 'async_trait,
J::Payload: Encode,
Self: 'async_trait,
'life0: 'async_trait,
fn schedule<'life0, 'async_trait, J>(
&'life0 self,
payload: J::Payload,
priority: i8,
) -> Pin<Box<dyn Future<Output = Result<Xid, QueueError>> + Send + 'async_trait>>where
J: JobProcessor + 'static + 'async_trait,
J::Payload: Encode,
Self: 'async_trait,
'life0: 'async_trait,
Schedule a job to run next. Depending on queue backlog this may start running later than you expect.
Sourcefn schedule_in<'life0, 'async_trait, J>(
&'life0 self,
payload: J::Payload,
scheduled_in: Duration,
priority: i8,
) -> Pin<Box<dyn Future<Output = Result<Xid, QueueError>> + Send + 'async_trait>>where
J: JobProcessor + 'static + 'async_trait,
J::Payload: Encode,
Self: 'async_trait,
'life0: 'async_trait,
fn schedule_in<'life0, 'async_trait, J>(
&'life0 self,
payload: J::Payload,
scheduled_in: Duration,
priority: i8,
) -> Pin<Box<dyn Future<Output = Result<Xid, QueueError>> + Send + 'async_trait>>where
J: JobProcessor + 'static + 'async_trait,
J::Payload: Encode,
Self: 'async_trait,
'life0: 'async_trait,
Schedule a job to run at the future time relative to now.
Sourcefn poll_next<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_types: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Option<Self::JobHandle>, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn poll_next<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_types: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Option<Self::JobHandle>, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Pool queue, implementation should not wait for next job, if there nothing return Ok(None).
Sourcefn next<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_types: &'life1 [&'life2 str],
interval: Duration,
) -> Pin<Box<dyn Future<Output = Result<Self::JobHandle, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn next<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_types: &'life1 [&'life2 str],
interval: Duration,
) -> Pin<Box<dyn Future<Output = Result<Self::JobHandle, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Await next job. Default implementation polls the queue with defined interval until there is something.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.