pub struct BatcherHandle<T> { /* private fields */ }Expand description
A handle to the background batcher worker.
This handle is cheap to clone and can be shared across threads. It provides methods to insert rows and control the batcher lifecycle.
Implementations§
Source§impl<T: ClickInsertable + Send + 'static> BatcherHandle<T>
impl<T: ClickInsertable + Send + 'static> BatcherHandle<T>
Sourcepub async fn insert(&self, row: T) -> Result<()>
pub async fn insert(&self, row: T) -> Result<()>
Insert a single row into the batch.
This method waits if the internal channel is full (Backpressure). Use this for data integrity when you want to slow down the producer rather than dropping data.
§Errors
Returns an error if the batcher worker has terminated.
Sourcepub fn try_insert(&self, row: T) -> Result<()>
pub fn try_insert(&self, row: T) -> Result<()>
Try to insert a single row without blocking.
This method fails immediately if the channel is full (Load Shedding). Use this for high-availability scenarios where dropping data is preferable to blocking the application.
§Errors
Returns Channel full if the channel is at capacity.
Returns Channel closed if the worker has terminated.
Sourcepub async fn insert_many(&self, rows: Vec<T>) -> Result<()>
pub async fn insert_many(&self, rows: Vec<T>) -> Result<()>
Insert multiple rows into the batch.
This treats the vector as a single unit for channel capacity purposes.
Sourcepub async fn flush(&self) -> Result<FlushStats>
pub async fn flush(&self) -> Result<FlushStats>
Force a flush of the current buffer and wait for completion.
This ensures all data currently in the buffer is sent to ClickHouse.
Trait Implementations§
Source§impl<T: Clone> Clone for BatcherHandle<T>
impl<T: Clone> Clone for BatcherHandle<T>
Source§fn clone(&self) -> BatcherHandle<T>
fn clone(&self) -> BatcherHandle<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more