jobq: stamp created_at on every node, beside started_at/finished_at
`Node` carried two of the three lifecycle timestamps; the third lived on hive-c0re's `NodeKind::Dag` container payload, a core-specific wrapper the graph knows nothing about. Give it its real home so the container's copy becomes redundant rather than load-bearing. Not an `Option` like its neighbours: starting and finishing are events that may never happen, but a node that exists was created. Modelling it as optional would encode a state the graph cannot be in. `hive-jobq-wire::GraphNode` gains the field in the same commit — it already carries the other two, and without this one the value cannot reach a viewer when the container's copy is deleted.
This commit is contained in:
parent
238a99ba08
commit
24cd7f6d65
2 changed files with 19 additions and 3 deletions
|
|
@ -152,6 +152,9 @@ pub struct GraphNode {
|
|||
/// What must hold before this node runs. Omitted when empty.
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub deps: Vec<GraphDep>,
|
||||
/// When the node was inserted into the graph. Always present — a node that
|
||||
/// exists was created, so unlike the two below this is not an `Option`.
|
||||
pub created_at: DateTime<Utc>,
|
||||
/// When the node entered `Running`. `None` until it starts; a node that
|
||||
/// never ran keeps `None`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
|
|
@ -254,6 +257,7 @@ fn wire_node<N: WireNode, R: WireResource>(node: &hive_jobq::Node<N, R>) -> Grap
|
|||
parent: node.parent.map(NodeId::get),
|
||||
state: node.state,
|
||||
deps: node.deps.iter().map(wire_dep).collect(),
|
||||
created_at: node.created_at,
|
||||
started_at: node.started_at,
|
||||
finished_at: node.finished_at,
|
||||
error: node.error.clone(),
|
||||
|
|
@ -443,6 +447,7 @@ mod tests {
|
|||
parent,
|
||||
state,
|
||||
deps,
|
||||
created_at: chrono::DateTime::<chrono::Utc>::default(),
|
||||
started_at: None,
|
||||
finished_at: None,
|
||||
error: None,
|
||||
|
|
|
|||
Loading…
Reference in a new issue