pub struct AppendStream { /* private fields */ }Expand description
Cloneable handle to a bounded background append stream.
Admitted rows belong to the stream rather than an individual producer call.
Call flush to await an intermediate barrier or shutdown
to close admission and await final settlement. If all handles are dropped
without calling shutdown, the background worker drains already admitted
rows while the Tokio runtime remains active.
Implementations§
Source§impl AppendStream
impl AppendStream
Sourcepub fn try_send<T>(&self, row: &T) -> Result<(), AppendTrySendError>
pub fn try_send<T>(&self, row: &T) -> Result<(), AppendTrySendError>
Attempts to serialize and admit row without waiting for local buffer capacity.
Rejected rows increment AppendStreamStats::dropped_rows and
AppendStreamStats::dropped_by_reason.
Sourcepub async fn send_all<I>(&self, rows: I) -> Result<AppendAdmissionResult, Error>
pub async fn send_all<I>(&self, rows: I) -> Result<AppendAdmissionResult, Error>
Serializes and admits an iterator of rows sequentially, awaiting local buffer capacity as needed.
If an item fails encoding or the stream closes mid-iteration,
Error::append_admission reports how many rows from this call were
admitted. Those rows remain owned by the stream; call flush or
shutdown to observe their delivery.
Dropping this future stops admitting further rows while leaving already
admitted rows in the stream.
Sourcepub async fn flush(&self) -> Result<AppendDeliveryReport, Error>
pub async fn flush(&self) -> Result<AppendDeliveryReport, Error>
Dispatches buffered rows and waits for all rows admitted before this call to settle.
Returns an AppendDeliveryReport covering activity since the previous
completed barrier while keeping the stream open. Under
AppendFailurePolicy::Stop, a batch failure transitions the stream to
AppendStreamState::Failed, settles all in-flight batches, and
returns Error with the terminal Error::append_delivery_report
(shared with any concurrent flush or shutdown callers).
Under AppendFailurePolicy::Continue, flush returns Ok(report)
and records any batch losses in report.outcome.
Once the barrier is enqueued, dropping this future stops waiting without cancelling settlement in the background worker.
Sourcepub async fn shutdown(&self) -> Result<AppendDeliveryReport, Error>
pub async fn shutdown(&self) -> Result<AppendDeliveryReport, Error>
Closes row admission, settles all admitted rows, and returns the final
AppendDeliveryReport.
Idempotent across cloned handles: concurrent and subsequent calls
observe the same terminal result (or Error::append_delivery_report
on a AppendFailurePolicy::Stop failure). Dropping the future stops
local waiting while background settlement continues; call shutdown
again to await completion.
Sourcepub fn stats(&self) -> AppendStreamStats
pub fn stats(&self) -> AppendStreamStats
Returns a point-in-time snapshot of cumulative stream counters, state, and the latest report.