mod config;
mod db;
mod dispatcher;
mod error;
mod job;
mod migration;
mod worker;
pub use config::QueueConfig;
pub use db::{
claim, delete_job, enqueue, fail_job, get_delayed_jobs, get_failed_jobs, get_pending_jobs,
get_stats, reaper, release_job, requeue_claimed_by, FailedJobInfo, JobInfo, JobRow, JobState,
Queue, QueueStats, SingleQueueStats,
};
pub use dispatcher::{
dispatch, dispatch_later, dispatch_to, register_tenant_capture_hook, PendingDispatch,
};
pub use error::Error;
pub use job::{Job, JobPayload};
pub use migration::CreateJobsTable;
pub use worker::{TenantScopeProvider, Worker, WorkerConfig, WorkerLoop};
pub use async_trait::async_trait;
pub trait Queueable: Job + serde::Serialize + serde::de::DeserializeOwned {
fn dispatch(self) -> PendingDispatch<Self>
where
Self: Sized,
{
PendingDispatch::new(self)
}
fn delay(self, duration: std::time::Duration) -> PendingDispatch<Self>
where
Self: Sized,
{
PendingDispatch::new(self).delay(duration)
}
fn on_queue(self, queue: &'static str) -> PendingDispatch<Self>
where
Self: Sized,
{
PendingDispatch::new(self).on_queue(queue)
}
}
impl<T> Queueable for T where T: Job + serde::Serialize + serde::de::DeserializeOwned {}