Skip to main content

Broker

Trait Broker 

Source
pub trait Broker:
    Send
    + Sync
    + 'static {
    // Required methods
    fn enqueue<'life0, 'async_trait>(
        &'life0 self,
        message: TaskMessage,
    ) -> Pin<Box<dyn Future<Output = Result<(), KojinError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn dequeue<'life0, 'life1, 'async_trait>(
        &'life0 self,
        queues: &'life1 [String],
        timeout: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<Option<TaskMessage>, KojinError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn ack<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 TaskId,
    ) -> Pin<Box<dyn Future<Output = Result<(), KojinError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn nack<'life0, 'async_trait>(
        &'life0 self,
        message: TaskMessage,
    ) -> Pin<Box<dyn Future<Output = Result<(), KojinError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn dead_letter<'life0, 'async_trait>(
        &'life0 self,
        message: TaskMessage,
    ) -> Pin<Box<dyn Future<Output = Result<(), KojinError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn schedule<'life0, 'async_trait>(
        &'life0 self,
        message: TaskMessage,
        eta: DateTime<Utc>,
    ) -> Pin<Box<dyn Future<Output = Result<(), KojinError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn queue_len<'life0, 'life1, 'async_trait>(
        &'life0 self,
        queue: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<usize, KojinError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

Message broker responsible for enqueuing and dequeuing task messages.

Required Methods§

Source

fn enqueue<'life0, 'async_trait>( &'life0 self, message: TaskMessage, ) -> Pin<Box<dyn Future<Output = Result<(), KojinError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Push a message onto a queue.

Source

fn dequeue<'life0, 'life1, 'async_trait>( &'life0 self, queues: &'life1 [String], timeout: Duration, ) -> Pin<Box<dyn Future<Output = Result<Option<TaskMessage>, KojinError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Blocking dequeue from one of the given queues. Returns None if shutdown is signaled or timeout occurs.

Source

fn ack<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 TaskId, ) -> Pin<Box<dyn Future<Output = Result<(), KojinError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Acknowledge successful processing — remove from processing queue.

Source

fn nack<'life0, 'async_trait>( &'life0 self, message: TaskMessage, ) -> Pin<Box<dyn Future<Output = Result<(), KojinError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Negative acknowledge — message will be re-enqueued or dead-lettered.

Source

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

Move a message to the dead-letter queue.

Source

fn schedule<'life0, 'async_trait>( &'life0 self, message: TaskMessage, eta: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<(), KojinError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Schedule a message for future delivery.

Source

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

Get the length of a queue.

Implementors§