Coverage for src / lexigram / contracts / data / timeseries / protocols.py: 0%
11 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
1"""Time-series database protocols for event and metric storage.
3Provides driver-agnostic abstractions for time-series stores
4(TimescaleDB, InfluxDB, etc.) supporting continuous event insertion
5and windowed querying.
6"""
8from __future__ import annotations
10from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable
12if TYPE_CHECKING:
13 from lexigram.contracts.core.health import HealthCheckResult
16@runtime_checkable
17class TimeSeriesStoreProtocol(Protocol):
18 """Protocol for a time-series database provider.
20 Provides continuous data stream ingestion, windowed queries, and
21 lifecycle management.
22 """
24 async def connect(self) -> None:
25 """Establish connection to the time-series store."""
26 ...
28 async def disconnect(self) -> None:
29 """Close all connections."""
30 ...
32 def is_connected(self) -> bool:
33 """Check if the store is connected."""
34 ...
36 async def insert(self, series: str, data: list[dict[str, Any]]) -> None:
37 """Insert sequence data points into a specific series/measurement.
39 Args:
40 series: The series, measurement, or bucket name.
41 data: Data points, typically including a timestamp and values.
42 """
43 ...
45 async def query(
46 self,
47 series: str,
48 start_time: Any,
49 end_time: Any,
50 filter: dict[str, Any] | None = None,
51 ) -> list[dict[str, Any]]:
52 """Query data points within a time window.
54 Args:
55 series: The series name to query.
56 start_time: Timestamp representing the beginning of the window.
57 end_time: Timestamp representing the end of the window.
58 filter: Optional tags/metadata to filter on.
60 Returns:
61 List of matched data point dicts.
62 """
63 ...
65 async def health_check(self, timeout: float = 5.0) -> HealthCheckResult:
66 """Check time-series store connectivity and health."""
67 ...
70__all__ = [
71 "TimeSeriesStoreProtocol",
72]