Skip to main content

TransportReceiver

Trait TransportReceiver 

Source
pub trait TransportReceiver: TransportBase {
    type Token: CommitToken;

    // Required methods
    fn recv(
        &self,
        max: usize,
    ) -> impl Future<Output = TransportResult<Vec<Message<Self::Token>>>> + Send;
    fn commit(
        &self,
        tokens: &[Self::Token],
    ) -> impl Future<Output = TransportResult<()>> + Send;

    // Provided method
    fn take_filtered_dlq_entries(&self) -> Vec<FilteredDlqEntry> { ... }
}
Available on crate feature transport only.
Expand description

Receive-side transport – generic over commit token type.

Extends TransportBase with receive and commit capability. Input stages (receiver, fetcher) use concrete implementations directly for type-safe token handling.

Required Associated Types§

Source

type Token: CommitToken

The token type for this transport.

Required Methods§

Source

fn recv( &self, max: usize, ) -> impl Future<Output = TransportResult<Vec<Message<Self::Token>>>> + Send

Receive up to max messages.

Returns immediately with available messages (may be fewer than max). Returns empty vec if no messages are available.

Filter behaviour: if the transport has inbound filters configured, recv() removes messages that match action: drop filters and stages messages matching action: dlq filters into an internal queue. Use take_filtered_dlq_entries after each recv() call to retrieve the staged DLQ entries and route them via your DLQ handle.

Source

fn commit( &self, tokens: &[Self::Token], ) -> impl Future<Output = TransportResult<()>> + Send

Commit/acknowledge processed messages.

  • Kafka: commits consumer offsets
  • gRPC: no-op (no persistence)
  • Redis: XACK
  • File: advances read position
  • Memory: advances internal sequence

Provided Methods§

Source

fn take_filtered_dlq_entries(&self) -> Vec<FilteredDlqEntry>

Drain DLQ entries staged by inbound filtering.

When a transport’s inbound filters classify messages as action: dlq, the messages are removed from the recv() result and staged in an internal queue. Call this method after each recv() to drain the staged entries and route them to your DLQ.

Default implementation returns an empty vec – transports without filter support don’t need to override this.

§Example
let messages = transport.recv(100).await?;
for entry in transport.take_filtered_dlq_entries() {
    dlq.send(DlqEntry::new("filter", entry.reason, entry.payload)).await?;
}
// Process passing messages...

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§