nodedb_types/timeseries/sync.rs
1//! Sync delta and WAL payload types.
2
3use serde::{Deserialize, Serialize};
4
5use super::series::{LiteId, SeriesId, SeriesKey};
6
7/// Wire format for Lite→Origin timeseries delta exchange.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct TimeseriesDelta {
10 /// Source Lite instance ID (CUID2).
11 pub source_id: LiteId,
12 /// Series identifier (metric + tags hash).
13 pub series_id: SeriesId,
14 /// Canonical series key for the source.
15 pub series_key: SeriesKey,
16 /// Minimum timestamp in this block.
17 pub min_ts: i64,
18 /// Maximum timestamp in this block.
19 pub max_ts: i64,
20 /// Gorilla-encoded compressed samples.
21 pub encoded_block: Vec<u8>,
22 /// Number of samples in the block.
23 pub sample_count: u64,
24}
25
26/// WAL record payload for a timeseries metric batch.
27#[derive(
28 Debug, Clone, Serialize, Deserialize, zerompk::ToMessagePack, zerompk::FromMessagePack,
29)]
30pub struct TimeseriesWalBatch {
31 /// Collection name.
32 pub collection: String,
33 /// Batch of metric samples: (series_id, timestamp_ms, value).
34 pub samples: Vec<(SeriesId, i64, f64)>,
35}
36
37/// WAL record payload for a timeseries log batch.
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct LogWalBatch {
40 /// Collection name.
41 pub collection: String,
42 /// Batch of log entries: (series_id, timestamp_ms, data).
43 pub entries: Vec<(SeriesId, i64, Vec<u8>)>,
44}