mas_storage::queue

Trait QueueJobRepository

source
pub trait QueueJobRepository: Send + Sync {
    type Error;

    // Required method
    fn schedule<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 mut self,
        rng: &'life1 mut (dyn RngCore + Send),
        clock: &'life2 dyn Clock,
        queue_name: &'life3 str,
        payload: Value,
        metadata: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

A QueueJobRepository is used to schedule jobs to be executed by a worker.

Required Associated Types§

source

type Error

The error type returned by the repository.

Required Methods§

source

fn schedule<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, queue_name: &'life3 str, payload: Value, metadata: Value, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Schedule a job to be executed as soon as possible by a worker.

§Parameters
  • rng - The random number generator used to generate a new job ID
  • clock - The clock used to generate timestamps
  • queue_name - The name of the queue to schedule the job on
  • payload - The payload of the job
  • metadata - Arbitrary metadata about the job scheduled immediately.
§Errors

Returns an error if the underlying repository fails.

Implementations on Foreign Types§

source§

impl<R> QueueJobRepository for Box<R>

source§

type Error = <R as QueueJobRepository>::Error

source§

fn schedule<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, rng: &'life1 mut (dyn RngCore + Send), clock: &'life2 dyn Clock, queue_name: &'life3 str, payload: Value, metadata: Value, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Implementors§

source§

impl<R, F, E> QueueJobRepository for MapErr<R, F>
where R: QueueJobRepository, F: FnMut(<R as QueueJobRepository>::Error) -> E + Send + Sync,

source§

type Error = E