Skip to main content

atomr_telemetry/
dto.rs

1//! Serde DTOs shared between the telemetry bus, REST handlers, and the
2//! React dashboard. Kept in one file so the whole wire format is visible
3//! at a glance.
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct ActorStatus {
9    pub path: String,
10    pub parent: Option<String>,
11    pub actor_type: String,
12    pub mailbox_depth: u64,
13    pub spawned_at: String,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct ActorTreeNode {
18    pub path: String,
19    pub name: String,
20    pub actor_type: String,
21    pub mailbox_depth: u64,
22    pub children: Vec<ActorTreeNode>,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize, Default)]
26pub struct ActorSnapshot {
27    pub total: u64,
28    pub roots: Vec<ActorTreeNode>,
29    pub flat: Vec<ActorStatus>,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct DeadLetterRecord {
34    pub seq: u64,
35    pub recipient: String,
36    pub sender: Option<String>,
37    pub message_type: String,
38    pub message_preview: String,
39    pub timestamp: String,
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize, Default)]
43pub struct ClusterMemberInfo {
44    pub address: String,
45    pub status: String,
46    pub roles: Vec<String>,
47    pub reachable: bool,
48    pub up_number: i32,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize, Default)]
52pub struct ClusterStateInfo {
53    pub self_address: Option<String>,
54    pub leader: Option<String>,
55    pub members: Vec<ClusterMemberInfo>,
56    pub unreachable: Vec<String>,
57    pub reachability_records: Vec<ReachabilityRecord>,
58    pub gossip_version: Vec<(String, u64)>,
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
62pub struct ReachabilityRecord {
63    pub observer: String,
64    pub subject: String,
65    pub status: String,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
69pub struct ClusterMembershipDiff {
70    pub added: Vec<ClusterMemberInfo>,
71    pub updated: Vec<ClusterMemberInfo>,
72    pub removed: Vec<String>,
73    pub became_unreachable: Vec<String>,
74    pub became_reachable: Vec<String>,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize, Default)]
78pub struct ShardRegionInfo {
79    pub region_id: String,
80    pub shard_count: usize,
81    pub shards: Vec<String>,
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize, Default)]
85pub struct ShardingSnapshot {
86    pub regions: Vec<ShardRegionInfo>,
87    pub allocations: Vec<(String, String)>,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize)]
91pub struct ShardingEvent {
92    pub region_id: String,
93    pub shard_id: String,
94    pub event: String,
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize, Default)]
98pub struct PersistenceSnapshot {
99    pub journals: Vec<JournalInfo>,
100    pub total_events: u64,
101    pub recent_writes: Vec<JournalWriteInfo>,
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize, Default)]
105pub struct JournalInfo {
106    pub name: String,
107    pub persistence_ids: Vec<PersistenceIdStat>,
108}
109
110#[derive(Debug, Clone, Serialize, Deserialize)]
111pub struct PersistenceIdStat {
112    pub persistence_id: String,
113    pub highest_sequence_nr: u64,
114    pub event_count: u64,
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize)]
118pub struct JournalWriteInfo {
119    pub journal: String,
120    pub persistence_id: String,
121    pub sequence_nr: u64,
122    pub timestamp: String,
123}
124
125#[derive(Debug, Clone, Serialize, Deserialize, Default)]
126pub struct RemoteSnapshot {
127    pub associations: Vec<RemoteAssociationInfo>,
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
131pub struct RemoteAssociationInfo {
132    pub remote_address: String,
133    pub state: String,
134    pub inbound_bytes: u64,
135    pub outbound_bytes: u64,
136}
137
138#[derive(Debug, Clone, Serialize, Deserialize, Default)]
139pub struct StreamsSnapshot {
140    pub running_graphs: u64,
141    pub total_started: u64,
142    pub total_finished: u64,
143    pub active: Vec<StreamGraphInfo>,
144}
145
146#[derive(Debug, Clone, Serialize, Deserialize)]
147pub struct StreamGraphInfo {
148    pub id: u64,
149    pub name: String,
150    pub started_at: String,
151}
152
153#[derive(Debug, Clone, Serialize, Deserialize, Default)]
154pub struct DDataSnapshot {
155    pub keys: Vec<String>,
156    pub total_updates: u64,
157}
158
159#[derive(Debug, Clone, Serialize, Deserialize)]
160pub struct NodeSnapshot {
161    pub node: String,
162    pub generated_at: String,
163    pub actors: ActorSnapshot,
164    pub dead_letters: Vec<DeadLetterRecord>,
165    pub cluster: ClusterStateInfo,
166    pub sharding: ShardingSnapshot,
167    pub persistence: PersistenceSnapshot,
168    pub remote: RemoteSnapshot,
169    pub streams: StreamsSnapshot,
170    pub ddata: DDataSnapshot,
171}
172
173#[derive(Debug, Clone, Serialize, Deserialize)]
174pub struct OverviewSnapshot {
175    pub node: String,
176    pub generated_at: String,
177    pub actor_count: u64,
178    pub dead_letter_count: u64,
179    pub cluster_member_count: usize,
180    pub cluster_unreachable_count: usize,
181    pub remote_association_count: usize,
182    pub running_graphs: u64,
183    pub persistence_event_count: u64,
184    pub ddata_key_count: usize,
185}