faucet_source_clickhouse/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! # faucet-source-clickhouse
4//!
5//! ClickHouse query source for the
6//! [`faucet-stream`](https://crates.io/crates/faucet-stream) ecosystem, built on
7//! the ClickHouse [HTTP interface](https://clickhouse.com/docs/en/interfaces/http)
8//! via [`reqwest`](https://crates.io/crates/reqwest).
9//!
10//! Runs a SQL `SELECT`, streams the `JSONEachRow` response body straight into
11//! [`StreamPage`](faucet_core::StreamPage)s (bytes are line-buffered and decoded
12//! incrementally, so memory stays bounded regardless of result size), and
13//! supports incremental replication via a tracking column (see
14//! [`ClickHouseReplication`]). Mirrors the `faucet-source-postgres` / `mysql` /
15//! `mssql` query sources.
16//!
17//! ```no_run
18//! # use faucet_source_clickhouse::{ClickHouseSource, ClickHouseSourceConfig};
19//! # fn run() -> Result<(), faucet_core::FaucetError> {
20//! let cfg = ClickHouseSourceConfig::new(
21//! "http://localhost:8123",
22//! "SELECT id, email, updated_at FROM events",
23//! );
24//! let source = ClickHouseSource::new(cfg)?;
25//! # let _ = source;
26//! # Ok(())
27//! # }
28//! ```
29
30mod config;
31mod stream;
32
33pub use config::{ClickHouseReplication, ClickHouseSourceConfig};
34pub use stream::ClickHouseSource;
35
36// Re-export the shared connection type so users configure the source without
37// depending on `faucet-common-clickhouse` directly.
38pub use faucet_common_clickhouse::ClickHouseConnection;