Skip to main content

MessageTransport

Trait MessageTransport 

Source
pub trait MessageTransport:
    Send
    + Sync
    + 'static {
    // Required methods
    fn poll(
        &self,
        max: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<InboundMessage>, Box<dyn Error + Sync + Send>>> + Send + '_>>;
    fn ack<'a>(
        &'a self,
        msg: &'a InboundMessage,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>>;
    fn nack<'a>(
        &'a self,
        msg: &'a InboundMessage,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>>;
    fn dead_letter<'a>(
        &'a self,
        msg: &'a InboundMessage,
        reason: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>>;
}
Expand description

App-provided broker adapter (Kafka / AMQP / NATS / in-process bridge).

Required Methods§

Source

fn poll( &self, max: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<InboundMessage>, Box<dyn Error + Sync + Send>>> + Send + '_>>

Pull up to max messages. An empty Vec means “nothing right now”.

Source

fn ack<'a>( &'a self, msg: &'a InboundMessage, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>>

Acknowledge successful processing (message will not be redelivered).

Source

fn nack<'a>( &'a self, msg: &'a InboundMessage, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>>

Negative-ack: requeue for a later retry.

Source

fn dead_letter<'a>( &'a self, msg: &'a InboundMessage, reason: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Sync + Send>>> + Send + 'a>>

Park a poison message out of band, with the final failure reason.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§