admin / Syanpse-Vanguard
public
Syanpse-Vanguard / synapse-vanguard-v3 / sv / storage / clickhouse_engine.py
1773 B · main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | """ClickHouse scale-out backend — placeholder implementing the same interface. Wired into build_engine() so `SV_STORAGE_BACKEND=clickhouse` selects it without any caller changes. Bodies are intentionally left for the scale-out milestone; the point here is that the abstraction boundary already exists and the rest of the app is decoupled from the driver.""" from __future__ import annotations from datetime import datetime from typing import AsyncIterator, Sequence import pyarrow as pa from sv.models.event import EventModel from sv.storage.base import Query, StorageEngine class ClickHouseEngine(StorageEngine): def __init__(self, dsn: str | None): if not dsn: raise ValueError("SV_CLICKHOUSE_DSN is required for the clickhouse backend") self._dsn = dsn async def init_schema(self) -> None: raise NotImplementedError("ClickHouse backend lands in the scale-out milestone") async def write_batch(self, events: Sequence[EventModel]) -> int: raise NotImplementedError async def execute(self, query: Query) -> pa.Table: raise NotImplementedError async def stream(self, query: Query, batch_rows: int = 10_000 ) -> AsyncIterator[pa.RecordBatch]: raise NotImplementedError yield # pragma: no cover (makes this an async generator) async def retention_sweep(self, older_than: datetime) -> int: raise NotImplementedError async def fetchone(self, query: Query) -> dict | None: raise NotImplementedError async def fetchall(self, query: Query) -> list[dict]: raise NotImplementedError async def run(self, query: Query) -> None: raise NotImplementedError async def close(self) -> None: return None |