remove what no longer has a reader: build-log store, dashboard sent/delivered events, graph resource dep
This commit is contained in:
parent
32f5b74ba4
commit
49266e4410
1 changed files with 204 additions and 1054 deletions
|
|
@ -22,10 +22,6 @@ const DASHBOARD_CHANNEL: usize = 256;
|
|||
|
||||
pub struct Coordinator {
|
||||
pub broker: Arc<Broker>,
|
||||
/// Full build-log capture. `lifecycle::run` `start()`s a row per attempt,
|
||||
/// pipes every stdout/stderr line into it, and `finish()`es it on
|
||||
/// child exit. See `build_logs.rs` for retention.
|
||||
pub build_logs: Arc<crate::build_logs::BuildLogs>,
|
||||
/// Store path of the hyperhive flake source (no fragment). Used to
|
||||
/// identify the running revision (`current_flake_rev`).
|
||||
pub hyperhive_flake: String,
|
||||
|
|
@ -110,9 +106,8 @@ pub struct Coordinator {
|
|||
/// publisher sends the change at once instead of at its next sweep.
|
||||
updating_changed: tokio::sync::Notify,
|
||||
/// Unified wire-facing event channel feeding the dashboard SSE
|
||||
/// stream. Carries broker messages (mirrored from `broker.subscribe`
|
||||
/// by the forwarder task in `main.rs`) and dashboard-only mutation
|
||||
/// events (container state, rebuild queue, etc.).
|
||||
/// stream. Carries the dashboard mutation events (container state,
|
||||
/// rebuild queue, etc.).
|
||||
dashboard_events: broadcast::Sender<DashboardEvent>,
|
||||
|
||||
/// Last container snapshot seen by `rescan_containers_and_emit`,
|
||||
|
|
@ -331,33 +326,11 @@ impl Coordinator {
|
|||
agent_io_weight,
|
||||
} = env;
|
||||
let broker = Broker::open(db_path).context("open broker")?;
|
||||
// BuildLogs wants a directory (it picks its own `build_logs.sqlite`
|
||||
// file under it); every other opener here takes the sibling
|
||||
// sqlite-file path itself. Derive the dir from `db_path`'s
|
||||
// parent so the two shapes line up.
|
||||
let build_logs_dir = db_path.parent().unwrap_or_else(|| Path::new("."));
|
||||
let build_logs = Arc::new(
|
||||
crate::build_logs::BuildLogs::open(build_logs_dir).context("open build_logs")?,
|
||||
);
|
||||
// This process is the database's only writer and has started no
|
||||
// build yet, so a row still in-flight belongs to a dead process.
|
||||
let reaped = build_logs.reap_orphans()?;
|
||||
if reaped > 0 {
|
||||
tracing::warn!(
|
||||
reaped,
|
||||
"build_logs: closed rows left in-flight by a previous run"
|
||||
);
|
||||
}
|
||||
// Install the process-wide handle so `lifecycle::run` can write
|
||||
// without us having to thread an `Arc<BuildLogs>` through every public entry
|
||||
// point in the lifecycle surface.
|
||||
crate::build_logs::install(build_logs.clone());
|
||||
let power = Arc::new(crate::power::PowerStore::default());
|
||||
let (dashboard_events, _) = broadcast::channel(DASHBOARD_CHANNEL);
|
||||
let (shutdown_tx, _) = watch::channel(false);
|
||||
Ok(Self {
|
||||
broker: Arc::new(broker),
|
||||
build_logs,
|
||||
hyperhive_flake,
|
||||
claude_code_path,
|
||||
dashboard_port,
|
||||
|
|
@ -447,8 +420,7 @@ impl Coordinator {
|
|||
}
|
||||
|
||||
/// Subscribe to the unified dashboard event channel. Used by the
|
||||
/// `/dashboard/stream` SSE handler and by the broker-to-dashboard
|
||||
/// forwarder task.
|
||||
/// `/dashboard/stream` SSE handler.
|
||||
pub fn dashboard_subscribe(&self) -> broadcast::Receiver<DashboardEvent> {
|
||||
self.dashboard_events.subscribe()
|
||||
}
|
||||
|
|
@ -1004,29 +976,3 @@ mod agent_paths_tests {
|
|||
assert_eq!(paths.agent, std::path::PathBuf::from("/run/x"));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod open_tests {
|
||||
use super::{Coordinator, HiveEnv};
|
||||
|
||||
fn open(db: &std::path::Path) -> Coordinator {
|
||||
Coordinator::open(db, HiveEnv::default(), 1).expect("open coordinator")
|
||||
}
|
||||
|
||||
/// A build log row the previous process left open is closed as failed
|
||||
/// when the next one opens the coordinator.
|
||||
#[tokio::test]
|
||||
async fn open_closes_build_logs_left_in_flight() {
|
||||
let dir = tempfile::tempdir().expect("tempdir");
|
||||
let db = dir.path().join("broker.sqlite");
|
||||
let id = open(&db)
|
||||
.build_logs
|
||||
.start("alice", "run", "cmd", None)
|
||||
.expect("start");
|
||||
|
||||
let coord = open(&db);
|
||||
let row = coord.build_logs.get_full(id).expect("get").expect("Some");
|
||||
assert_eq!(row.status.as_deref(), Some("fail"));
|
||||
assert!(row.finished_at.is_some());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue