Skip to main content

entrenar/monitor/storage/
traits.rs

1//! Metrics storage trait definitions
2
3use super::error::StorageResult;
4use crate::monitor::{Metric, MetricRecord, MetricStats};
5
6/// Metrics storage backend trait
7pub trait MetricsStore: Send + Sync {
8    /// Write a batch of metric records
9    fn write_batch(&mut self, records: &[MetricRecord]) -> StorageResult<()>;
10
11    /// Query metrics by name within a time range
12    fn query_range(
13        &self,
14        metric: &Metric,
15        start_ts: u64,
16        end_ts: u64,
17    ) -> StorageResult<Vec<MetricRecord>>;
18
19    /// Get all records for a metric
20    fn query_all(&self, metric: &Metric) -> StorageResult<Vec<MetricRecord>>;
21
22    /// Get summary statistics for a metric
23    fn query_stats(&self, metric: &Metric) -> StorageResult<Option<MetricStats>>;
24
25    /// Get total record count
26    fn count(&self) -> StorageResult<usize>;
27
28    /// Flush pending writes
29    fn flush(&mut self) -> StorageResult<()>;
30}