Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Nodes

Nodes implement the GraphNode trait or use FnNode / add_node_fn for closure-based nodes. Each node receives a snapshot of all channel values and a context providing stream_tx, cancel signal, and interrupt handling.

#![allow(unused)]
fn main() {
graph.add_node_fn("my_node", |state, ctx| async move {
    // state: snapshot of all channel values
    // ctx: provides stream_tx, cancel signal, interrupt

    let mut out = HashMap::new();
    out.insert("result".into(), json!("done"));
    Ok(NodeOutput::Update(out))
});
}

NodeOutput variants

  • Update(values) — Pure state update. The engine uses edges for routing; the next node is determined by the graph topology.
  • Command { goto, update } — The node decides where to go next. Bypasses edge routing; goto specifies the next node directly.