pub struct ClickHouseConfig {Show 14 fields
pub url: String,
pub table: String,
pub database: Option<String>,
pub username: Option<String>,
pub password: Option<String>,
pub max_batch_rows: usize,
pub max_retries: u32,
pub base_retry_delay: Duration,
pub max_retry_delay: Duration,
pub connect_timeout: Duration,
pub read_timeout: Duration,
pub gzip: bool,
pub workers: usize,
pub spill_dir: Option<PathBuf>,
}Expand description
Configuration for the ClickHouse writer.
Fields§
§url: StringClickHouse HTTP endpoint (e.g. http://localhost:8123 or https://...).
HTTPS requires the tls feature (enabled by default).
table: StringTarget table name for INSERT INTO ... FORMAT ArrowStream.
database: Option<String>Optional target database. When set, sent via X-ClickHouse-Database.
username: Option<String>Optional ClickHouse username. When set, sent via X-ClickHouse-User.
password: Option<String>Optional ClickHouse password/key. When set, sent via X-ClickHouse-Key.
max_batch_rows: usizeAdvisory target batch size in rows.
This field is an advisory hint for upstream batching code (such as
CollectArrowBridge or
TelemetryPipeline) that decide when to
flush a partially-filled Arrow batch toward the writer. The writer
itself does not split, merge, or reject batches based on this
value — whatever RecordBatch is handed to
ClickHouseWriter::send is serialized and sent as-is.
Keep this in sync with the batch_size you pass to
CollectArrowBridge::new, or read it back from the config to drive
that call.
max_retries: u32Maximum number of retry attempts per batch.
base_retry_delay: DurationBase delay for exponential backoff (default 100 ms).
Retry N sleeps for base_retry_delay x 2^(N-1) plus jitter.
max_retry_delay: DurationMaximum backoff cap (default 10 s).
The computed delay is clamped to this value before jitter is applied.
connect_timeout: DurationTCP connect timeout (default 10 s).
read_timeout: DurationHTTP read timeout per request (default 60 s).
gzip: boolIf true and the gzip feature is enabled, compress request bodies.
Has no effect when the gzip feature is disabled.
workers: usizeNumber of background writer threads draining the channel in parallel.
Defaults to 1 (single-threaded writer preserving submission order).
Values greater than 1 allow multiple concurrent HTTP requests to
ClickHouse, which is useful when per-batch request latency is the
bottleneck. Ordering between batches is not preserved with
workers > 1; if downstream consumers rely on the submission order,
keep this at 1.
spill_dir: Option<PathBuf>Optional directory where batches that fail all retries are persisted to disk as Arrow IPC files.
Requires the spill feature. When set, a batch that exhausts every
retry is written to
spill_dir/batch-{unix_nanos}-{pid}-{seq}.arrows instead of being
silently dropped. Replay from disk is not automatic and is left to
the operator (e.g. a separate ingest job).
When the feature is disabled this field is ignored.
Implementations§
Source§impl ClickHouseConfig
impl ClickHouseConfig
Sourcepub fn new(url: impl Into<String>, table: impl Into<String>) -> Self
pub fn new(url: impl Into<String>, table: impl Into<String>) -> Self
Create a config with the given endpoint URL and table name.
All other settings use sensible defaults and can be overridden with the builder-style methods below.
Sourcepub fn with_max_batch_rows(self, max_batch_rows: usize) -> Self
pub fn with_max_batch_rows(self, max_batch_rows: usize) -> Self
Override the advisory batch-row target (see
max_batch_rows).
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
Override the maximum retry count.
Sourcepub fn with_base_retry_delay(self, base_retry_delay: Duration) -> Self
pub fn with_base_retry_delay(self, base_retry_delay: Duration) -> Self
Override the base retry delay.
Sourcepub fn with_max_retry_delay(self, max_retry_delay: Duration) -> Self
pub fn with_max_retry_delay(self, max_retry_delay: Duration) -> Self
Override the maximum retry delay.
Sourcepub fn with_auth(
self,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn with_auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
Set ClickHouse authentication credentials (sent via
X-ClickHouse-User / X-ClickHouse-Key headers).
Sourcepub fn with_database(self, database: impl Into<String>) -> Self
pub fn with_database(self, database: impl Into<String>) -> Self
Set the target database (sent via X-ClickHouse-Database).
Sourcepub fn with_timeouts(self, connect: Duration, read: Duration) -> Self
pub fn with_timeouts(self, connect: Duration, read: Duration) -> Self
Set TCP connect and HTTP read timeouts.
Sourcepub fn with_gzip(self, enabled: bool) -> Self
pub fn with_gzip(self, enabled: bool) -> Self
Enable or disable gzip request-body compression.
Requires the gzip Cargo feature to have an effect.
Sourcepub fn with_workers(self, workers: usize) -> Self
pub fn with_workers(self, workers: usize) -> Self
Override the number of concurrent background writer threads.
See workers for caveats about ordering.
Values less than 1 are clamped to 1.
Sourcepub fn with_spill_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_spill_dir(self, dir: impl Into<PathBuf>) -> Self
Enable on-disk spill for undelivered batches.
Requires the spill Cargo feature to have an effect. The directory
is created on first spill if it does not already exist.
Trait Implementations§
Source§impl Clone for ClickHouseConfig
impl Clone for ClickHouseConfig
Source§fn clone(&self) -> ClickHouseConfig
fn clone(&self) -> ClickHouseConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more