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