Skip to main content

JobBackend

Trait JobBackend 

Source
pub trait JobBackend: Send + Sync {
    // Required methods
    fn push<'life0, 'async_trait>(
        &'life0 self,
        job: JobRequest,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn pop<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<JobRequest>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn complete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        job_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn fail<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        job_id: &'life1 str,
        error: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Backend storage for jobs

Required Methods§

Source

fn push<'life0, 'async_trait>( &'life0 self, job: JobRequest, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Push a new job to the queue

Source

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

Pop the next available job Should return None if no job is available or ready

Source

fn complete<'life0, 'life1, 'async_trait>( &'life0 self, job_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Mark a job as completed successfully

Source

fn fail<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, job_id: &'life1 str, error: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Mark a job as failed The manager will decide whether to retry (re-push) or move to DLQ

Implementors§