Skip to main content

Backend

Trait Backend 

Source
pub trait Backend:
    Send
    + Sync
    + 'static {
    // Required methods
    fn declare<'life0, 'life1, 'async_trait>(
        &'life0 self,
        queues: &'life1 [QueueConfig],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn publish<'life0, 'life1, 'async_trait>(
        &'life0 self,
        envelope: &'life1 Envelope,
        delay: Option<Duration>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn defer<'life0, 'life1, 'async_trait>(
        &'life0 self,
        envelope: &'life1 Envelope,
        delay: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn consume<'life0, 'life1, 'async_trait>(
        &'life0 self,
        queue: &'life1 QueueConfig,
    ) -> Pin<Box<dyn Future<Output = Result<DeliveryStream>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn close<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A transport. Implementations: MemoryBackend (this crate), RabbitMqBackend.

Required Methods§

Source

fn declare<'life0, 'life1, 'async_trait>( &'life0 self, queues: &'life1 [QueueConfig], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Idempotently create all queues (plus any retry / dead-letter infrastructure).

Source

fn publish<'life0, 'life1, 'async_trait>( &'life0 self, envelope: &'life1 Envelope, delay: Option<Duration>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Publish envelope to envelope.queue, optionally delayed.

Source

fn defer<'life0, 'life1, 'async_trait>( &'life0 self, envelope: &'life1 Envelope, delay: Duration, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Publish envelope into a hold that releases it onto envelope.queue after delay. This is the publish half of Delivery::defer, also used by crate::Producer::defer.

Differs from publish with a delay: that one shares a single wait queue per queue (on RabbitMQ q.retry, where mixed per-message TTLs block each other at the head) and the message returns with whatever priority it carries. A deferral is held per delay, so equal delays drain strictly in order, and the envelope is expected to carry the queue’s top priority so it overtakes the backlog.

Hold queue naming and lifetime are backend-specific.

Source

fn consume<'life0, 'life1, 'async_trait>( &'life0 self, queue: &'life1 QueueConfig, ) -> Pin<Box<dyn Future<Output = Result<DeliveryStream>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Start consuming queue with the given prefetch. The stream ends when the backend is closed or the connection is lost.

Source

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

Graceful shutdown: stop all consumers, flush, close connections.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§