Skip to main content

ClickHouseConfig

Struct ClickHouseConfig 

Source
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: String

ClickHouse HTTP endpoint (e.g. http://localhost:8123 or https://...).

HTTPS requires the tls feature (enabled by default).

§table: String

Target 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: usize

Advisory 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: u32

Maximum number of retry attempts per batch.

§base_retry_delay: Duration

Base delay for exponential backoff (default 100 ms).

Retry N sleeps for base_retry_delay x 2^(N-1) plus jitter.

§max_retry_delay: Duration

Maximum backoff cap (default 10 s).

The computed delay is clamped to this value before jitter is applied.

§connect_timeout: Duration

TCP connect timeout (default 10 s).

§read_timeout: Duration

HTTP read timeout per request (default 60 s).

§gzip: bool

If true and the gzip feature is enabled, compress request bodies.

Has no effect when the gzip feature is disabled.

§workers: usize

Number 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

Source

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.

Source

pub fn with_max_batch_rows(self, max_batch_rows: usize) -> Self

Override the advisory batch-row target (see max_batch_rows).

Source

pub fn with_max_retries(self, max_retries: u32) -> Self

Override the maximum retry count.

Source

pub fn with_base_retry_delay(self, base_retry_delay: Duration) -> Self

Override the base retry delay.

Source

pub fn with_max_retry_delay(self, max_retry_delay: Duration) -> Self

Override the maximum retry delay.

Source

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).

Source

pub fn with_database(self, database: impl Into<String>) -> Self

Set the target database (sent via X-ClickHouse-Database).

Source

pub fn with_timeouts(self, connect: Duration, read: Duration) -> Self

Set TCP connect and HTTP read timeouts.

Source

pub fn with_gzip(self, enabled: bool) -> Self

Enable or disable gzip request-body compression.

Requires the gzip Cargo feature to have an effect.

Source

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.

Source

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

Source§

fn clone(&self) -> ClickHouseConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClickHouseConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClickHouseConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,