Trait QueueBackend

Source
pub trait QueueBackend: Send + Sync {
    // Required methods
    fn enqueue<'life0, 'async_trait>(
        &'life0 self,
        job: JobEntry,
    ) -> Pin<Box<dyn Future<Output = QueueResult<JobId>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn dequeue<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = QueueResult<Option<JobEntry>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn complete<'life0, 'async_trait>(
        &'life0 self,
        job_id: JobId,
        result: JobResult<()>,
    ) -> Pin<Box<dyn Future<Output = QueueResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_job<'life0, 'async_trait>(
        &'life0 self,
        job_id: JobId,
    ) -> Pin<Box<dyn Future<Output = QueueResult<Option<JobEntry>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_jobs_by_state<'life0, 'async_trait>(
        &'life0 self,
        state: JobState,
        limit: Option<usize>,
    ) -> Pin<Box<dyn Future<Output = QueueResult<Vec<JobEntry>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn remove_job<'life0, 'async_trait>(
        &'life0 self,
        job_id: JobId,
    ) -> Pin<Box<dyn Future<Output = QueueResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn clear<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = QueueResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stats<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = QueueResult<QueueStats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn requeue_job<'life0, 'async_trait>(
        &'life0 self,
        job_id: JobId,
        job: JobEntry,
    ) -> Pin<Box<dyn Future<Output = QueueResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn clear_jobs_by_state<'life0, 'async_trait>(
        &'life0 self,
        state: JobState,
    ) -> Pin<Box<dyn Future<Output = QueueResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Core queue backend trait that all queue implementations must implement

Required Methods§

Source

fn enqueue<'life0, 'async_trait>( &'life0 self, job: JobEntry, ) -> Pin<Box<dyn Future<Output = QueueResult<JobId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enqueue a job

Source

fn dequeue<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = QueueResult<Option<JobEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Dequeue the next available job

Source

fn complete<'life0, 'async_trait>( &'life0 self, job_id: JobId, result: JobResult<()>, ) -> Pin<Box<dyn Future<Output = QueueResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mark a job as completed

Source

fn get_job<'life0, 'async_trait>( &'life0 self, job_id: JobId, ) -> Pin<Box<dyn Future<Output = QueueResult<Option<JobEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get job by ID

Source

fn get_jobs_by_state<'life0, 'async_trait>( &'life0 self, state: JobState, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = QueueResult<Vec<JobEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get jobs by state

Source

fn remove_job<'life0, 'async_trait>( &'life0 self, job_id: JobId, ) -> Pin<Box<dyn Future<Output = QueueResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a job from the queue

Source

fn clear<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = QueueResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear all jobs from the queue

Source

fn stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = QueueResult<QueueStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get queue statistics

Provided Methods§

Source

fn requeue_job<'life0, 'async_trait>( &'life0 self, job_id: JobId, job: JobEntry, ) -> Pin<Box<dyn Future<Output = QueueResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Atomically requeue a job (remove old and enqueue new) Default implementation is non-atomic for backward compatibility

Source

fn clear_jobs_by_state<'life0, 'async_trait>( &'life0 self, state: JobState, ) -> Pin<Box<dyn Future<Output = QueueResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Atomically clear all jobs in a specific state Default implementation is non-atomic for backward compatibility

Implementors§