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.

Extends TransportBase with send capability. The factory returns AnySender (enum dispatch) for runtime transport selection.

All implementations auto-emit dfe_transport_* Prometheus 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 string when None) and its payload Bytes (a refcount bump, not a copy). Transports with a native batch RPC (e.g. gRPC’s RouteBatch) override this to send the whole block in a single call – serde-less and round-trip-cheaper.

Commit tokens and inline-DLQ entries are NOT sent: they are the SENDER’s local concern. Pass the records (e.g. &workbatch.records) and fire the commit tokens locally after this returns SendResult::Ok.

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

The default is NOT atomic. If record k of n returns a non-Ok result, records 0..k are already on the wire and this returns that first non-Ok result WITHOUT unsending them. The caller treats the whole block as not-yet-committed and retries it; the already-sent prefix is re-delivered (at-least-once – duplicates, never loss). A Backpressured or Fatal short-circuits (no further records are attempted) so the caller retries the remainder rather than skipping past a transient failure. A native batch override (gRPC) avoids the partial-send window entirely: the whole block is one RPC, accepted or not.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§