job_queue: move the jobs wire types to hive-host-sock
The DagView / NodeView / Source / State / PermPayload types only ever travel on the host admin socket and the dashboard channels hive-c0re serves off the same snapshot; their whole consumer set is hive-c0re, hivectl and the socket protocol crate itself. Living in hive-sh4re made the five other crates that depend on it carry job-queue types they never name. Pure move: git mv of the module plus the import sweep, no type changes. hive-sh4re keeps its own chrono (wire_time still needs it).
This commit is contained in:
parent
8a7a450240
commit
a8728ac532
8 changed files with 39 additions and 27 deletions
|
|
@ -66,7 +66,7 @@ async fn wait_for_dags_plain(socket: &Path, ids: Vec<u64>) -> Result<()> {
|
|||
// may still be running — keep watching so the operator
|
||||
// sees whether the agent came back.
|
||||
if d.nodes.iter().all(|n| n.state.is_terminal()) {
|
||||
if d.rollup_state() == hive_sh4re::jobs::State::Failed {
|
||||
if d.rollup_state() == hive_host_sock::jobs::State::Failed {
|
||||
failed.push(format!("{} {}", d.source.as_str(), dag_agents(d)));
|
||||
}
|
||||
} else {
|
||||
|
|
@ -104,9 +104,9 @@ async fn wait_for_dags_animated(socket: &Path, ids: Vec<u64>) -> Result<()> {
|
|||
// insertion order groups a DAG's nodes right under its header.
|
||||
let mut dag_bars: std::collections::HashMap<u64, ProgressBar> =
|
||||
std::collections::HashMap::new();
|
||||
let mut node_bars: std::collections::HashMap<(u64, hive_sh4re::jobs::NodeId), ProgressBar> =
|
||||
let mut node_bars: std::collections::HashMap<(u64, hive_host_sock::jobs::NodeId), ProgressBar> =
|
||||
std::collections::HashMap::new();
|
||||
let mut node_done: std::collections::HashSet<(u64, hive_sh4re::jobs::NodeId)> =
|
||||
let mut node_done: std::collections::HashSet<(u64, hive_host_sock::jobs::NodeId)> =
|
||||
std::collections::HashSet::new();
|
||||
|
||||
let mut pending: std::collections::BTreeSet<u64> = ids.into_iter().collect();
|
||||
|
|
@ -163,7 +163,7 @@ async fn wait_for_dags_animated(socket: &Path, ids: Vec<u64>) -> Result<()> {
|
|||
}
|
||||
}
|
||||
if d.nodes.iter().all(|n| n.state.is_terminal()) {
|
||||
if d.rollup_state() == hive_sh4re::jobs::State::Failed {
|
||||
if d.rollup_state() == hive_host_sock::jobs::State::Failed {
|
||||
failed.push(format!("{} {}", d.source.as_str(), dag_agents(d)));
|
||||
}
|
||||
} else {
|
||||
|
|
@ -205,7 +205,7 @@ fn finish_wait(mut failed: Vec<String>) -> Result<()> {
|
|||
/// Distinct agents across a DAG's nodes, comma-joined for display — the
|
||||
/// per-node replacement for the old DAG-level `agent` field. Single-agent
|
||||
/// DAGs render one name; a hive-wide DAG lists each.
|
||||
fn dag_agents(d: &hive_sh4re::jobs::DagView) -> String {
|
||||
fn dag_agents(d: &hive_host_sock::jobs::DagView) -> String {
|
||||
let mut seen: Vec<&str> = Vec::new();
|
||||
for n in &d.nodes {
|
||||
if !seen.contains(&n.agent.as_str()) {
|
||||
|
|
@ -227,7 +227,7 @@ fn now_unix() -> i64 {
|
|||
/// Elapsed seconds for a DAG: `started_at` (falling back to `created_at`)
|
||||
/// through `finished_at` or `now`. The wire carries these as RFC3339
|
||||
/// `DateTime<Utc>`; compare in unix seconds against `now`.
|
||||
fn dag_elapsed(d: &hive_sh4re::jobs::DagView, now: i64) -> i64 {
|
||||
fn dag_elapsed(d: &hive_host_sock::jobs::DagView, now: i64) -> i64 {
|
||||
let start = d
|
||||
.started_at
|
||||
.map_or_else(|| d.created_at.timestamp(), |t| t.timestamp());
|
||||
|
|
@ -236,7 +236,7 @@ fn dag_elapsed(d: &hive_sh4re::jobs::DagView, now: i64) -> i64 {
|
|||
|
||||
/// Elapsed seconds for a node: `started_at` → `finished_at`/`now`, or 0
|
||||
/// when it hasn't started.
|
||||
fn node_elapsed(n: &hive_sh4re::jobs::NodeView, now: i64) -> i64 {
|
||||
fn node_elapsed(n: &hive_host_sock::jobs::NodeView, now: i64) -> i64 {
|
||||
match n.started_at {
|
||||
Some(start) => (n.finished_at.map_or(now, |t| t.timestamp()) - start.timestamp()).max(0),
|
||||
None => 0,
|
||||
|
|
@ -255,7 +255,11 @@ fn fmt_dur(secs: i64) -> String {
|
|||
|
||||
/// One animated node line: kind, an `(after …)` marker for a fan-in node
|
||||
/// (>1 dep), its elapsed timer, and a truncated error tail.
|
||||
fn node_line(d: &hive_sh4re::jobs::DagView, n: &hive_sh4re::jobs::NodeView, now: i64) -> String {
|
||||
fn node_line(
|
||||
d: &hive_host_sock::jobs::DagView,
|
||||
n: &hive_host_sock::jobs::NodeView,
|
||||
now: i64,
|
||||
) -> String {
|
||||
use std::fmt::Write as _;
|
||||
let mut s = n.kind.clone();
|
||||
if n.deps.len() > 1 {
|
||||
|
|
@ -280,13 +284,13 @@ fn node_line(d: &hive_sh4re::jobs::DagView, n: &hive_sh4re::jobs::NodeView, now:
|
|||
s
|
||||
}
|
||||
|
||||
fn state_glyph(state: hive_sh4re::jobs::State) -> &'static str {
|
||||
fn state_glyph(state: hive_host_sock::jobs::State) -> &'static str {
|
||||
match state {
|
||||
hive_sh4re::jobs::State::Queued => "⏸",
|
||||
hive_sh4re::jobs::State::Running => "▶",
|
||||
hive_sh4re::jobs::State::Done => "✔",
|
||||
hive_sh4re::jobs::State::Failed => "✖",
|
||||
hive_sh4re::jobs::State::Cancelled => "⊘",
|
||||
hive_host_sock::jobs::State::Queued => "⏸",
|
||||
hive_host_sock::jobs::State::Running => "▶",
|
||||
hive_host_sock::jobs::State::Done => "✔",
|
||||
hive_host_sock::jobs::State::Failed => "✖",
|
||||
hive_host_sock::jobs::State::Cancelled => "⊘",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -294,7 +298,7 @@ fn state_glyph(state: hive_sh4re::jobs::State) -> &'static str {
|
|||
/// node chain — the CLI twin of the dashboard's queue card. The header shows
|
||||
/// what the backend sends (`source` + the raw node kinds); only the roll-up
|
||||
/// state glyph is derived from the node set. Used by the plain (non-TTY) path.
|
||||
fn render_dag_line(d: &hive_sh4re::jobs::DagView) -> String {
|
||||
fn render_dag_line(d: &hive_host_sock::jobs::DagView) -> String {
|
||||
use std::fmt::Write as _;
|
||||
let mut out = format!(
|
||||
"{} {} {:<12}",
|
||||
|
|
@ -315,7 +319,7 @@ fn render_dag_line(d: &hive_sh4re::jobs::DagView) -> String {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use hive_sh4re::jobs::{DagView, NodeView, Source, State};
|
||||
use hive_host_sock::jobs::{DagView, NodeView, Source, State};
|
||||
use hive_sh4re::wire_time::from_secs;
|
||||
|
||||
use super::render_dag_line;
|
||||
|
|
|
|||
Loading…
Reference in a new issue