pub struct ClickHouseEventsBackend(/* private fields */);Expand description
Remote ClickHouse structured-event storage.
connect opens the ClickHouse client and creates the Spectra events table
when needed. Pair it with ClickHouseMetricsBackend because Spectra::builder() requires
both storage paths.
§Examples
Facade wiring through Spectra::builder() (requires the spectra crate with the
clickhouse feature):
ⓘ
use std::sync::Arc;
use spectra::{ClickHouseEventsBackend, ClickHouseMetricsBackend, Spectra};
let url = "http://127.0.0.1:8123";
let spectra = Spectra::builder()
.metrics_backend(Arc::new(ClickHouseMetricsBackend::connect(url).await?))
.events_backend(Arc::new(ClickHouseEventsBackend::connect(url).await?))
.build()?;Implementations§
Source§impl ClickHouseEventsBackend
impl ClickHouseEventsBackend
Sourcepub async fn connect(url: &str) -> Result<ClickHouseEventsBackend, Error>
pub async fn connect(url: &str) -> Result<ClickHouseEventsBackend, Error>
Connect to ClickHouse over HTTP or native protocol and ensure event tables exist.
url is typically http://host:8123. The call is async and executes DDL, so the
ClickHouse credentials need table-creation permission.
§Examples
ⓘ
use spectra_backend_clickhouse::ClickHouseEventsBackend;
let backend = ClickHouseEventsBackend::connect("http://127.0.0.1:8123").await?;Sourcepub fn in_memory_stub() -> ClickHouseEventsBackend
pub fn in_memory_stub() -> ClickHouseEventsBackend
In-memory stub that preserves the ClickHouse engine type for storage-contract tests.
§Examples
use spectra_backend_clickhouse::ClickHouseEventsBackend;
use spectra_core::{EventStorageBackend, StorageEngineType};
let backend = ClickHouseEventsBackend::in_memory_stub();
assert_eq!(backend.engine_type(), StorageEngineType::ClickHouse);Trait Implementations§
Source§impl EventStorageBackend for ClickHouseEventsBackend
impl EventStorageBackend for ClickHouseEventsBackend
Source§fn engine_type(&self) -> StorageEngineType
fn engine_type(&self) -> StorageEngineType
Returns the engine type for this backend.
Source§fn append_row<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
table: &'life1 str,
fields: &'life2 Value,
ts: DateTime<Utc>,
correlation_id: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
ClickHouseEventsBackend: 'async_trait,
fn append_row<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
table: &'life1 str,
fields: &'life2 Value,
ts: DateTime<Utc>,
correlation_id: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
ClickHouseEventsBackend: 'async_trait,
Appends one event row.
Source§fn append_rows_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
rows: &'life1 [EventWriteRow],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ClickHouseEventsBackend: 'async_trait,
fn append_rows_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
rows: &'life1 [EventWriteRow],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
ClickHouseEventsBackend: 'async_trait,
Batch append event rows (default: per-row dispatch).
Source§fn query_rows<'life0, 'async_trait>(
&'life0 self,
filter: EventsQueryFilter,
) -> Pin<Box<dyn Future<Output = Result<Vec<EventRow>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
ClickHouseEventsBackend: 'async_trait,
fn query_rows<'life0, 'async_trait>(
&'life0 self,
filter: EventsQueryFilter,
) -> Pin<Box<dyn Future<Output = Result<Vec<EventRow>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
ClickHouseEventsBackend: 'async_trait,
Queries event rows matching the filter.
Source§fn query_aggregate<'life0, 'async_trait>(
&'life0 self,
filter: EventsAggregateFilter,
) -> Pin<Box<dyn Future<Output = Result<EventAggregateResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
ClickHouseEventsBackend: 'async_trait,
fn query_aggregate<'life0, 'async_trait>(
&'life0 self,
filter: EventsAggregateFilter,
) -> Pin<Box<dyn Future<Output = Result<EventAggregateResult, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
ClickHouseEventsBackend: 'async_trait,
Queries aggregated chart data.
Auto Trait Implementations§
impl !RefUnwindSafe for ClickHouseEventsBackend
impl !UnwindSafe for ClickHouseEventsBackend
impl Freeze for ClickHouseEventsBackend
impl Send for ClickHouseEventsBackend
impl Sync for ClickHouseEventsBackend
impl Unpin for ClickHouseEventsBackend
impl UnsafeUnpin for ClickHouseEventsBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more