Skip to main content

QueueBackend

Trait QueueBackend 

Source
pub trait QueueBackend:
    Send
    + Sync
    + 'static {
    // Required methods
    fn push<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        queue: &'life1 str,
        payload: &'life2 [u8],
        opts: PushOptions,
    ) -> Pin<Box<dyn Future<Output = Result<JobId, BackendError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn reserve<'life0, 'life1, 'async_trait>(
        &'life0 self,
        queue: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ReservedJob>, BackendError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn complete<'life0, 'async_trait>(
        &'life0 self,
        id: JobId,
    ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn fail<'life0, 'async_trait>(
        &'life0 self,
        id: JobId,
        retry_at: Option<Instant>,
    ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn dead_letter<'life0, 'async_trait>(
        &'life0 self,
        id: JobId,
    ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}
Expand description

Queue backend trait — async by design, since real backends are remote.

Required Methods§

Source

fn push<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, queue: &'life1 str, payload: &'life2 [u8], opts: PushOptions, ) -> Pin<Box<dyn Future<Output = Result<JobId, BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Push a payload onto a named queue, returning the job id.

Source

fn reserve<'life0, 'life1, 'async_trait>( &'life0 self, queue: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<ReservedJob>, BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Reserve the next ready job from a queue (FIFO, ready_at <= now).

Source

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

Mark a reserved job complete — no retries, no DLQ entry.

Source

fn fail<'life0, 'async_trait>( &'life0 self, id: JobId, retry_at: Option<Instant>, ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Mark a reserved job failed; if retry_at is set, requeue for that time.

Source

fn dead_letter<'life0, 'async_trait>( &'life0 self, id: JobId, ) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Move a job to the dead-letter queue (terminal failure).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§