Skip to main content

Module streaming

Module streaming 

Source
Expand description

Streaming query support for AmateRS SDK

Provides QueryStream — a bounded, cancellable stream of Rows produced by a background task. The stream implements futures::Stream so callers can use standard combinators (map, filter, collect, …).

§Design

  • Backpressure — The producer writes into a bounded tokio::sync::mpsc channel whose capacity is set by StreamConfig::buffer_size. The producer is forced to await once the channel is full, which naturally throttles generation rate to consumption rate.

  • Cancellation — A tokio_util::sync::CancellationToken is shared between the consumer and the background producer task. Dropping the QueryStream cancels the token, and the producer checks it before every send.

  • Lazy — The background task is spawned by QueryStream; no data is generated until QueryStream is polled.

The [spawn_stub_producer] helper is retained as a #[doc(hidden)] test utility; production code uses the real execute_stream RPC.

Structs§

QueryStream
A cancellable, backpressure-aware stream of Rows from a query.
Row
A single key-value result row returned from a streaming query.
RowSender
A handle used by the background producer task to send rows to the consumer and to detect cancellation.
StreamConfig
Configuration controlling backpressure and optional timeout for a QueryStream.