Skip to main content

QueueDriver

Trait QueueDriver 

Source
pub trait QueueDriver: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn push<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        queue: &'life1 str,
        name: &'life2 str,
        payload: &'life3 Value,
        available_at: DateTime<Utc>,
        unique_key: Option<&'life4 str>,
    ) -> Pin<Box<dyn Future<Output = CoreResult<Option<i64>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn claim<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        queues: &'life1 [String],
        retry_after: Duration,
        worker: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = CoreResult<Option<Queued>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn release<'life0, 'async_trait>(
        &'life0 self,
        id: i64,
        available_at: DateTime<Utc>,
    ) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete<'life0, 'async_trait>(
        &'life0 self,
        id: i64,
    ) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fail<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        job: &'life1 Queued,
        error: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = CoreResult<i64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn counts<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CoreResult<Vec<QueueCount>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn failed<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CoreResult<Vec<FailedJob>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn retry<'life0, 'async_trait>(
        &'life0 self,
        id: Option<i64>,
    ) -> Pin<Box<dyn Future<Output = CoreResult<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn forget<'life0, 'async_trait>(
        &'life0 self,
        id: Option<i64>,
    ) -> Pin<Box<dyn Future<Output = CoreResult<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn clear<'life0, 'life1, 'async_trait>(
        &'life0 self,
        queue: Option<&'life1 str>,
    ) -> Pin<Box<dyn Future<Output = CoreResult<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn ping<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Where jobs wait. Every method is one storage operation; the worker’s rules live in Worker.

Required Methods§

Source

fn name(&self) -> &'static str

Source

fn push<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, queue: &'life1 str, name: &'life2 str, payload: &'life3 Value, available_at: DateTime<Utc>, unique_key: Option<&'life4 str>, ) -> Pin<Box<dyn Future<Output = CoreResult<Option<i64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Stores a job; None when unique_key names one already waiting.

Source

fn claim<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, queues: &'life1 [String], retry_after: Duration, worker: &'life2 str, ) -> Pin<Box<dyn Future<Output = CoreResult<Option<Queued>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Claims the oldest job due on one of queues, or one whose claim is older than retry_after, for worker. Its attempts count this claim.

Source

fn release<'life0, 'async_trait>( &'life0 self, id: i64, available_at: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Puts a claimed job back, due at available_at.

Source

fn delete<'life0, 'async_trait>( &'life0 self, id: i64, ) -> Pin<Box<dyn Future<Output = CoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes a finished job.

Source

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

Moves a job to the failed list; returns the failed row’s id.

Source

fn counts<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CoreResult<Vec<QueueCount>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn failed<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = CoreResult<Vec<FailedJob>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn retry<'life0, 'async_trait>( &'life0 self, id: Option<i64>, ) -> Pin<Box<dyn Future<Output = CoreResult<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Puts a failed job (or every one, with None) back on its queue; returns how many moved.

Source

fn forget<'life0, 'async_trait>( &'life0 self, id: Option<i64>, ) -> Pin<Box<dyn Future<Output = CoreResult<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Drops a failed job (or every one, with None); returns how many went.

Source

fn clear<'life0, 'life1, 'async_trait>( &'life0 self, queue: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = CoreResult<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Drops every waiting job on queue, or on every queue with None.

Provided Methods§

Source

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

Checks the store answers; a driver with nothing to check says yes.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§