pub trait Transport: Sealed {
type Message: Send + Sync;
type Encoder: Encoder<Message = Self::Message>;
// Required methods
fn send<'life0, 'life1, 'async_trait>(
&'life0 mut self,
stream_id: &'life1 Uuid,
message: Self::Message,
) -> Pin<Box<dyn Future<Output = Result<(), SendError<Self::Message>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn send_requests<'life0, 'life1, 'async_trait, I>(
&'life0 mut self,
stream_id: &'life1 Uuid,
requests: I,
) -> Pin<Box<dyn Future<Output = Result<(), SendError<Vec<Self::Message>>>> + Send + 'async_trait>>
where I: IntoIterator<Item = Self::Message> + Send + 'async_trait,
I::IntoIter: Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn try_send(
&mut self,
stream_id: &Uuid,
message: Self::Message,
) -> Result<(), TrySendError<Self::Message>>;
fn try_send_requests<I>(
&mut self,
stream_id: &Uuid,
requests: I,
) -> Result<(), TrySendError<Vec<Self::Message>>>
where I: IntoIterator<Item = Self::Message> + Send,
I::IntoIter: Send;
fn finish<'life0, 'async_trait>(
self,
stream_id: &'life0 Uuid,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Defines how encoded telemetry messages are delivered to their destination.
Three concrete implementations are provided:
LiveStreamingOnly— delivers messages to Sift in real-time over a single bounded ingestion channel. No checkpointing, no disk backups.LiveStreamingWithBackups— delivers messages to Sift in real-time with periodic checkpointing and disk backups. Uses a dual-channel architecture; see below.FileBackup— writes messages to rolling disk files without streaming live to Sift.
§Send API
Each implementation exposes four send methods that differ in their backpressure behaviour:
| Method | Blocks? | Error on failure |
|---|---|---|
send | Yes — awaits until the channel has capacity | SendError<T> with the undelivered message |
send_requests | Yes — per-message backpressure | SendError<Vec<T>> with all undelivered messages |
try_send | No — returns immediately | TrySendError<T> as Full(T) or Closed(T) |
try_send_requests | No — fails on first undeliverable message | TrySendError<Vec<T>> with all undelivered |
In every failure case the undelivered message(s) are returned inside the error variant so that the caller can decide whether to retry, log, buffer locally, or discard them.
§Backpressure sources
The channel that applies backpressure to send differs per mode. Knowing
which channel to tune is important when adjusting capacity via the mode builders:
| Mode | send awaits on | Capacity setting |
|---|---|---|
LiveStreamingOnly | ingestion channel | ingestion_data_channel_capacity |
LiveStreamingWithBackups | backup channel only — ingestion uses force-send | backup_data_channel_capacity |
FileBackup | write channel | backup_data_channel_capacity |
§Channel semantics for LiveStreamingWithBackups
LiveStreamingWithBackups maintains two internal bounded channels:
- backup channel — the primary durability path.
sendawaits here. - ingestion channel — forwards messages to the gRPC task using a force-send strategy: when full, the oldest buffered message is evicted to make room for the incoming one. Evicted messages are redirected to the backup channel.
Because of force-send eviction, the message returned inside an error variant from
send or send_requests may be an older
displaced message, not necessarily the one you just sent.
This trait is sealed: only implementations within this crate are permitted.
Required Associated Types§
Required Methods§
Sourcefn send<'life0, 'life1, 'async_trait>(
&'life0 mut self,
stream_id: &'life1 Uuid,
message: Self::Message,
) -> Pin<Box<dyn Future<Output = Result<(), SendError<Self::Message>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send<'life0, 'life1, 'async_trait>(
&'life0 mut self,
stream_id: &'life1 Uuid,
message: Self::Message,
) -> Pin<Box<dyn Future<Output = Result<(), SendError<Self::Message>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a single message with backpressure.
Awaits until the backing channel has capacity, then delivers the message.
§Errors
Returns SendError<Self::Message> containing a potentially undelivered message.
Depending on the implementation of Transport, the undelivered message is not
necessarily the message that was provided to the current invocation of Self::send.
See implementation documentation for details.
Sourcefn send_requests<'life0, 'life1, 'async_trait, I>(
&'life0 mut self,
stream_id: &'life1 Uuid,
requests: I,
) -> Pin<Box<dyn Future<Output = Result<(), SendError<Vec<Self::Message>>>> + Send + 'async_trait>>where
I: IntoIterator<Item = Self::Message> + Send + 'async_trait,
I::IntoIter: Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send_requests<'life0, 'life1, 'async_trait, I>(
&'life0 mut self,
stream_id: &'life1 Uuid,
requests: I,
) -> Pin<Box<dyn Future<Output = Result<(), SendError<Vec<Self::Message>>>> + Send + 'async_trait>>where
I: IntoIterator<Item = Self::Message> + Send + 'async_trait,
I::IntoIter: Send,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a batch of messages with backpressure.
Awaits channel capacity for each message in turn. Stops on the first failure and returns the failed message together with all remaining (not-yet-attempted) messages.
§Errors
Returns SendError<Vec<Self::Message>> containing potentially undelivered messages.
Depending on the implementation of Transport, the undelivered messages are not
necessarily the messages that were provided to the current invocation of Self::send_requests.
See implementation documentation for details.
Sourcefn try_send(
&mut self,
stream_id: &Uuid,
message: Self::Message,
) -> Result<(), TrySendError<Self::Message>>
fn try_send( &mut self, stream_id: &Uuid, message: Self::Message, ) -> Result<(), TrySendError<Self::Message>>
Attempt to send a single message without blocking.
Returns immediately regardless of whether the channel has capacity.
§Errors
Returns TrySendError<Self::Message> containing a potentially undelivered message:
TrySendError::Full— the channel is at capacity; consider retrying withsendto apply backpressure instead.TrySendError::Closed— the channel has been closed.
Depending on the implementation of Transport, the undelivered messages are not
necessarily the messages that were provided to the current invocation of Self::try_send.
See implementation documentation for details.
Sourcefn try_send_requests<I>(
&mut self,
stream_id: &Uuid,
requests: I,
) -> Result<(), TrySendError<Vec<Self::Message>>>
fn try_send_requests<I>( &mut self, stream_id: &Uuid, requests: I, ) -> Result<(), TrySendError<Vec<Self::Message>>>
Attempt to send a batch of messages without blocking.
Calls try_send for each message in turn. Returns immediately
on the first failure, bundling the failed message with any remaining unprocessed
messages.
§Errors
Returns TrySendError<Vec<Self::Message>> containing potentially undelivered messages.
TrySendError::Full— the channel was at capacity for one of the messages.TrySendError::Closed— the channel was closed.
Depending on the implementation of Transport, the undelivered messages are not
necessarily the messages that were provided to the current invocation of Self::try_send_requests.
See implementation documentation for details.
Sourcefn finish<'life0, 'async_trait>(
self,
stream_id: &'life0 Uuid,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn finish<'life0, 'async_trait>(
self,
stream_id: &'life0 Uuid,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Flush any remaining messages and cleanly shut down the transport.
Must be called when ingestion is complete. Dropping a SiftStream without
calling finish may result in tail-end data not reaching Sift.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.