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<RecvBatch<Self::Token>>> + Send;
    fn commit(
        &self,
        tokens: &[Self::Token],
    ) -> impl Future<Output = TransportResult<()>> + Send;
}
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<RecvBatch<Self::Token>>> + Send

Receive up to max messages.

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

Filter behaviour: if the transport has inbound filters configured, recv() removes messages matching action: drop filters and returns messages matching action: dlq filters in RecvBatch.dlq_entries alongside the passing RecvBatch.messages. Route the DLQ entries via your own DLQ handle – they cannot be silently lost.

§Example
let batch = transport.recv(100).await?;
for entry in batch.dlq_entries {
    dlq.send(DlqEntry::new("filter", entry.reason, entry.payload)).await?;
}
for msg in batch.messages { /* process */ }
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

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§