Skip to main content

TransportSender

Trait TransportSender 

Source
pub trait TransportSender: TransportBase {
    // Required method
    fn send(
        &self,
        key: &str,
        payload: Bytes,
    ) -> impl Future<Output = SendResult> + Send;

    // Provided method
    fn send_batch(
        &self,
        records: &[Record],
    ) -> impl Future<Output = SendResult> + Send { ... }
}
Available on crate feature transport only.
Expand description

Send-side transport.

The factory returns AnySender (enum dispatch) for runtime selection. All implementations auto-emit dfe_transport_* metrics when a MetricsManager recorder is installed.

Required Methods§

Source

fn send( &self, key: &str, payload: Bytes, ) -> impl Future<Output = SendResult> + Send

Send raw bytes to a key/destination.

The key semantics depend on the transport:

  • Kafka: topic name
  • gRPC: metadata routing key
  • HTTP: URL path suffix or ignored
  • File: filename suffix or ignored
  • Redis: stream name
  • Pipe: ignored (single stdout)

Provided Methods§

Source

fn send_batch( &self, records: &[Record], ) -> impl Future<Output = SendResult> + Send

Send a whole block of Records in one shot.

The default sends each record individually via send, using the record’s own key (empty when None) and payload (a refcount bump, not a copy). Transports with a native batch RPC (e.g. gRPC’s RouteBatch) override this. Commit tokens and inline-DLQ entries are NOT sent – they are the SENDER’s local concern; fire the commit tokens locally after this returns SendResult::Ok.

§At-least-once caveat – per-record fallback can partially send

Not atomic. If record k of n returns a transient non-Ok (Backpressured/Fatal), records 0..k are already on the wire and this returns without unsending them. The caller retries the whole block, re-delivering the sent prefix (at-least-once – duplicates, never loss). A native batch override (gRPC) sends the whole block as one RPC, avoiding the partial-send window.

§Outbound-filter dispositions do NOT abort the batch

A per-record FilteredDlq is the record being HANDLED, not a send failure: skip it and continue. Returning it would make the caller retry the whole block forever – the deterministic filter re-matches the same record every time (a livelock that stalls the source). Drop records likewise never reach the wire. Only Backpressured/Fatal short-circuit.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§