pub trait QueueDriver: Send + Sync {
Show 17 methods
// Required methods
fn push<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
job_name: &'life2 str,
payload: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn pop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<QueuedJob>, QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn mark_complete<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn mark_failed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
error: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn pending_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn push_at<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
job_name: &'life2 str,
payload: &'life3 str,
available_at: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn requeue<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn mark_complete_attempt<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
_attempt: u32,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn mark_failed_attempt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
_attempt: u32,
error: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn requeue_attempt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
_attempt: u32,
reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn requeue_attempt_after<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
_attempt: u32,
_reason: &'life2 str,
_delay: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn recover_stalled<'life0, 'async_trait>(
&'life0 self,
_stale_after: Duration,
) -> Pin<Box<dyn Future<Output = Result<u64, QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn list_all_jobs<'life0, 'async_trait>(
&'life0 self,
_limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueuedJobDetail>, QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn retry_failed_job<'life0, 'life1, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn purge_completed_jobs<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn purge_failed_jobs<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn purge_completed_history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Abstraction over queue storage backends.
Implement this trait to add support for new queue backends.
The framework ships with SqliteDriver and (optionally) RedisDriver.
Required Methods§
Sourcefn push<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
job_name: &'life2 str,
payload: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn push<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
job_name: &'life2 str,
payload: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Push a new job onto the queue.
Sourcefn pop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<QueuedJob>, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn pop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<QueuedJob>, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Pop the next available job from the queue (FIFO).
Worker always drives this future to completion and never cancels an
in-flight claim, so implementations may commit the claim before they
return. Graceful worker shutdown waits for that call, so it should not
block indefinitely.
Sourcefn mark_complete<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_complete<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Mark a job as successfully completed.
Drivers may remove it immediately or retain a bounded history under an explicit policy.
This transition is not fenced by claim; Worker uses
Self::mark_complete_attempt.
Sourcefn mark_failed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
error: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn mark_failed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
error: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Mark a job as failed, recording the error message.
Sourcefn pending_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn pending_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return the count of pending jobs.
Provided Methods§
Sourcefn push_at<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
job_name: &'life2 str,
payload: &'life3 str,
available_at: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn push_at<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 str,
job_name: &'life2 str,
payload: &'life3 str,
available_at: SystemTime,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Push a job that must not be claimed before available_at.
Custom drivers remain source-compatible. Their default implementation accepts jobs that are already due and fails closed for future delivery until the backend implements durable scheduling.
Sourcefn requeue<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn requeue<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Return an interrupted processing job to the pending state.
Sourcefn mark_complete_attempt<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
_attempt: u32,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_complete_attempt<'life0, 'life1, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
_attempt: u32,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Marks the exact claim returned by Self::pop as completed.
attempt is that claim’s QueuedJob::attempts value and acts as a
fencing token: the built-in drivers complete the job only while it is
still processing under the same attempt, so a worker whose lease was
recovered and claimed again cannot finish the newer claim. Worker
calls this method. The default delegates to Self::mark_complete
without a fence, so existing custom drivers keep their behaviour.
Sourcefn mark_failed_attempt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
_attempt: u32,
error: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn mark_failed_attempt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
_attempt: u32,
error: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Marks the exact claim returned by Self::pop as failed.
Fenced like Self::mark_complete_attempt; the default delegates to
Self::mark_failed.
Sourcefn requeue_attempt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
_attempt: u32,
reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn requeue_attempt<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
job_id: &'life1 str,
_attempt: u32,
reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Returns the exact claim returned by Self::pop to the pending state.
Fenced like Self::mark_complete_attempt; the default delegates to
Self::requeue.
Sourcefn requeue_attempt_after<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
_attempt: u32,
_reason: &'life2 str,
_delay: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn requeue_attempt_after<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
_attempt: u32,
_reason: &'life2 str,
_delay: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Returns the exact claim returned by Self::pop to the pending state,
not claimable again until delay has passed.
Worker uses this to hand back a job whose name it has no handler
for, so a worker that registered that name (for example a newer version
during a rolling deploy) can run it. Fenced like
Self::mark_complete_attempt. The default returns
QueueError::Unsupported, and the worker then fails the job instead.
Sourcefn recover_stalled<'life0, 'async_trait>(
&'life0 self,
_stale_after: Duration,
) -> Pin<Box<dyn Future<Output = Result<u64, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn recover_stalled<'life0, 'async_trait>(
&'life0 self,
_stale_after: Duration,
) -> Pin<Box<dyn Future<Output = Result<u64, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Recover processing leases left behind by a crashed worker.
The built-in SQLite and Redis drivers fail a job, instead of returning it to pending, when its lease has stalled five times, and report both requeued and failed leases in the returned count.
Sourcefn list_all_jobs<'life0, 'async_trait>(
&'life0 self,
_limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueuedJobDetail>, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_all_jobs<'life0, 'async_trait>(
&'life0 self,
_limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueuedJobDetail>, QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
List all recent jobs for monitoring
Sourcefn retry_failed_job<'life0, 'life1, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn retry_failed_job<'life0, 'life1, 'async_trait>(
&'life0 self,
_job_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retry a failed job
Sourcefn purge_completed_jobs<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn purge_completed_jobs<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Legacy, misnamed hook that purges failed jobs in the SQLite driver.
Sourcefn purge_failed_jobs<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn purge_failed_jobs<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Purge failed jobs retained by the backend.
Sourcefn purge_completed_history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn purge_completed_history<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), QueueError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Purge successful jobs retained by an explicit backend history policy.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".