pub struct Queue { /* private fields */ }Expand description
The main queue facade for dispatching background jobs.
Provides a driver-agnostic API. Create with Queue::sqlite() or Queue::redis().
Implementations§
Source§impl Queue
impl Queue
Sourcepub fn custom(driver: Box<dyn QueueDriver>) -> Self
pub fn custom(driver: Box<dyn QueueDriver>) -> Self
Create a queue from any custom driver implementing QueueDriver.
Sourcepub async fn dispatch(
&self,
job_name: &str,
payload: Value,
) -> Result<String, QueueError>
pub async fn dispatch( &self, job_name: &str, payload: Value, ) -> Result<String, QueueError>
Dispatch a named job with a JSON payload onto the queue.
Sourcepub async fn dispatch_at(
&self,
job_name: &str,
payload: Value,
available_at: SystemTime,
) -> Result<String, QueueError>
pub async fn dispatch_at( &self, job_name: &str, payload: Value, available_at: SystemTime, ) -> Result<String, QueueError>
Dispatches a durable job that cannot be claimed before available_at.
The built-in SQLite and Redis drivers support millisecond scheduling for at most 366 days ahead. Actual execution occurs on the first worker poll after the timestamp; wall-clock precision, provider acceptance, and exactly-once delivery are not implied.
Sourcepub async fn pending_count(&self) -> Result<u64, QueueError>
pub async fn pending_count(&self) -> Result<u64, QueueError>
Return the number of pending jobs in the queue.
Sourcepub async fn list_all_jobs(
&self,
limit: u32,
) -> Result<Vec<QueuedJobDetail>, QueueError>
pub async fn list_all_jobs( &self, limit: u32, ) -> Result<Vec<QueuedJobDetail>, QueueError>
List all recent jobs for visual monitoring
Sourcepub async fn retry_failed_job(&self, job_id: &str) -> Result<(), QueueError>
pub async fn retry_failed_job(&self, job_id: &str) -> Result<(), QueueError>
Retry a failed job in the queue
Sourcepub async fn purge_failed_jobs(&self) -> Result<(), QueueError>
pub async fn purge_failed_jobs(&self) -> Result<(), QueueError>
Purge failed jobs retained by the queue backend.
Sourcepub async fn purge_completed_history(&self) -> Result<(), QueueError>
pub async fn purge_completed_history(&self) -> Result<(), QueueError>
Purges successful jobs retained by the queue backend.
Sourcepub async fn purge_completed_jobs(&self) -> Result<(), QueueError>
👎Deprecated since 12.0.0: use purge_failed_jobs; this method has always targeted failed rows
pub async fn purge_completed_jobs(&self) -> Result<(), QueueError>
use purge_failed_jobs; this method has always targeted failed rows
Legacy compatibility name for Self::purge_failed_jobs.