drop hive and agent response fields the frontend never reads
This commit is contained in:
parent
1875181d59
commit
a437f9ccd5
1 changed files with 347 additions and 598 deletions
|
|
@ -1,7 +1,6 @@
|
|||
//! Unified dashboard event channel — all near-real-time browser events
|
||||
//! flow through `Coordinator.dashboard_events`. Each event carries a
|
||||
//! monotonic `seq` for client-side dedupe against `/api/state` snapshots.
|
||||
//! Design rationale (single channel, broker forwarder isolation):
|
||||
//! flow through `Coordinator.dashboard_events`. Design rationale
|
||||
//! (single channel, broker forwarder isolation):
|
||||
//! `docs/4-implementation/web-ui/shape.md::One unified channel`.
|
||||
|
||||
use serde::Serialize;
|
||||
|
|
@ -15,7 +14,6 @@ use chrono::{DateTime, Utc};
|
|||
pub enum DashboardEvent {
|
||||
/// Broker `Sent` event mirrored onto the dashboard channel.
|
||||
Sent {
|
||||
seq: u64,
|
||||
/// Broker row id. Allows the dashboard to track reply threads.
|
||||
id: i64,
|
||||
from: String,
|
||||
|
|
@ -27,7 +25,6 @@ pub enum DashboardEvent {
|
|||
},
|
||||
/// Broker `Delivered` event mirrored onto the dashboard channel.
|
||||
Delivered {
|
||||
seq: u64,
|
||||
/// Broker row id. Allows the dashboard to track reply threads.
|
||||
id: i64,
|
||||
from: String,
|
||||
|
|
@ -43,7 +40,6 @@ pub enum DashboardEvent {
|
|||
/// locally from `since_unix` so a slow rebuild's elapsed time
|
||||
/// ticks without polling.
|
||||
TransientSet {
|
||||
seq: u64,
|
||||
name: String,
|
||||
/// What the pill renders. For queue-driven work this is the running
|
||||
/// node's own wire tag (`"swap"`, `"create"`, `"stop_for_update"`, …) —
|
||||
|
|
@ -66,7 +62,6 @@ pub enum DashboardEvent {
|
|||
/// holding two open pills for one agent cannot tell which one cleared, and
|
||||
/// has to drop both or guess.
|
||||
TransientCleared {
|
||||
seq: u64,
|
||||
name: String,
|
||||
transient_kind: String,
|
||||
},
|
||||
|
|
@ -81,21 +76,18 @@ pub enum DashboardEvent {
|
|||
/// last one cached on the coordinator. Mutation sites (lifecycle
|
||||
/// endpoints, `actions::destroy`, `crash_watch`'s poll loop)
|
||||
/// call the rescan after their work lands.
|
||||
ContainerStateChanged { seq: u64, container: ContainerView },
|
||||
ContainerStateChanged { container: ContainerView },
|
||||
/// A container that was in the previous snapshot is gone. Clients
|
||||
/// drop the row by name. Fired alongside any
|
||||
/// `nixos-container destroy` (operator-driven or otherwise) on the
|
||||
/// next rescan.
|
||||
ContainerRemoved { seq: u64, name: String },
|
||||
ContainerRemoved { name: String },
|
||||
/// Full snapshot of the tombstones list. Emitted by destroy (with
|
||||
/// or without purge) and purge-tombstone. Snapshot
|
||||
/// shape (not diff) because the list is tiny (single-digit
|
||||
/// typical) and recomputing avoids the add/remove races a
|
||||
/// per-row event would have.
|
||||
TombstonesChanged {
|
||||
seq: u64,
|
||||
tombstones: Vec<TombstoneView>,
|
||||
},
|
||||
TombstonesChanged { tombstones: Vec<TombstoneView> },
|
||||
|
||||
/// The job queue changed — **a bare trigger, no payload.**
|
||||
///
|
||||
|
|
@ -110,7 +102,7 @@ pub enum DashboardEvent {
|
|||
/// push-on-change is what every other live surface here does
|
||||
/// (transients, container state), and a poll loop would be
|
||||
/// slower for the same information.
|
||||
RebuildQueueChanged { seq: u64 },
|
||||
RebuildQueueChanged,
|
||||
}
|
||||
|
||||
impl DashboardEvent {
|
||||
|
|
@ -135,7 +127,7 @@ impl DashboardEvent {
|
|||
DashboardEvent::ContainerRemoved { .. } => "container_removed",
|
||||
DashboardEvent::TombstonesChanged { .. } => "tombstones_changed",
|
||||
|
||||
DashboardEvent::RebuildQueueChanged { .. } => "rebuild_queue_changed",
|
||||
DashboardEvent::RebuildQueueChanged => "rebuild_queue_changed",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -163,7 +155,6 @@ mod tests {
|
|||
fn kind_tag_matches_serde_kind_field() {
|
||||
let samples: Vec<DashboardEvent> = vec![
|
||||
DashboardEvent::Sent {
|
||||
seq: 1,
|
||||
id: 1,
|
||||
from: "a".into(),
|
||||
to: "b".into(),
|
||||
|
|
@ -172,7 +163,6 @@ mod tests {
|
|||
in_reply_to: None,
|
||||
},
|
||||
DashboardEvent::Delivered {
|
||||
seq: 1,
|
||||
id: 1,
|
||||
from: "a".into(),
|
||||
to: "b".into(),
|
||||
|
|
@ -181,25 +171,19 @@ mod tests {
|
|||
in_reply_to: None,
|
||||
},
|
||||
DashboardEvent::TransientSet {
|
||||
seq: 1,
|
||||
name: "x".into(),
|
||||
transient_kind: "rebuilding".into(),
|
||||
since_unix: 0,
|
||||
},
|
||||
DashboardEvent::TransientCleared {
|
||||
seq: 1,
|
||||
name: "x".into(),
|
||||
transient_kind: "rebuilding".into(),
|
||||
},
|
||||
DashboardEvent::ContainerRemoved {
|
||||
seq: 1,
|
||||
name: "x".into(),
|
||||
},
|
||||
DashboardEvent::ContainerRemoved { name: "x".into() },
|
||||
DashboardEvent::TombstonesChanged {
|
||||
seq: 1,
|
||||
tombstones: Vec::new(),
|
||||
},
|
||||
DashboardEvent::RebuildQueueChanged { seq: 1 },
|
||||
DashboardEvent::RebuildQueueChanged,
|
||||
];
|
||||
for ev in samples {
|
||||
let v: serde_json::Value = serde_json::to_value(&ev).expect("serialise");
|
||||
|
|
@ -210,4 +194,40 @@ mod tests {
|
|||
assert_eq!(ev.kind_tag(), serde_kind, "kind_tag() drift on {ev:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Every frame is its `kind` tag plus the variant's own fields, nothing else.
|
||||
#[test]
|
||||
fn frames_carry_no_sequence_number() {
|
||||
let removed = serde_json::to_value(DashboardEvent::ContainerRemoved { name: "x".into() })
|
||||
.expect("serialise");
|
||||
let mut keys: Vec<&str> = removed
|
||||
.as_object()
|
||||
.unwrap()
|
||||
.keys()
|
||||
.map(String::as_str)
|
||||
.collect();
|
||||
keys.sort_unstable();
|
||||
assert_eq!(keys, ["kind", "name"]);
|
||||
|
||||
let transient = serde_json::to_value(DashboardEvent::TransientSet {
|
||||
name: "x".into(),
|
||||
transient_kind: "rebuilding".into(),
|
||||
since_unix: 0,
|
||||
})
|
||||
.expect("serialise");
|
||||
let mut keys: Vec<&str> = transient
|
||||
.as_object()
|
||||
.unwrap()
|
||||
.keys()
|
||||
.map(String::as_str)
|
||||
.collect();
|
||||
keys.sort_unstable();
|
||||
assert_eq!(keys, ["kind", "name", "since_unix", "transient_kind"]);
|
||||
|
||||
let trigger = serde_json::to_value(DashboardEvent::RebuildQueueChanged).expect("serialise");
|
||||
assert_eq!(
|
||||
trigger,
|
||||
serde_json::json!({ "kind": "rebuild_queue_changed" })
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue