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
use crate::ComponentId;
use bytes::Bytes;
use derive::FromValue;
use netidx_derive::Pack;
use serde::{Deserialize, Serialize};
use std::{collections::BTreeMap, sync::Arc};
use uuid::Uuid;

#[derive(Debug, Clone, Pack, FromValue, Serialize, Deserialize)]
pub enum SystemControlMessage {
    Snapshot(SystemSnapshot),
    DebugSnapshot(DebugSystemSnapshot), // for integration testing
    SymbologyReady,
    Shutdown,
    RestartComponent(ComponentId),
}

#[derive(Debug, Clone, Pack, Serialize, Deserialize)]
pub struct SystemSnapshot {
    pub core_id: Uuid,
    pub last_seqno: u64,
    pub last_remote_seqno: BTreeMap<Uuid, u64>,
    // id => (kind, json cfg, packed state)
    pub components: Arc<BTreeMap<ComponentId, (String, String, Bytes)>>,
}

#[derive(Debug, Clone, Pack, Serialize, Deserialize)]
pub struct DebugSystemSnapshot {
    pub core_id: Uuid,
    pub last_seqno: u64,
    pub last_remote_seqno: BTreeMap<Uuid, u64>,
    // id => (kind, json cfg, json state)
    pub components: Arc<BTreeMap<ComponentId, (String, String, String)>>,
}