pub struct NodeCtx<'a> {
pub run_id: Uuid,
pub step: u64,
pub config: &'a RunnableConfig,
/* private fields */
}Expand description
Per-superstep context handed to every Node::execute call. Carries
run-correlation metadata and the active RunnableConfig. The lifetime
is the superstep — don’t hold across awaits beyond execute returning.
Fields§
§run_id: UuidCorrelation ID for this run.
step: u64Superstep counter (0-indexed).
config: &'a RunnableConfigThe active runnable config (recursion_limit, observers, cancel_token, …).
Implementations§
Source§impl<'a> NodeCtx<'a>
impl<'a> NodeCtx<'a>
Sourcepub fn new(run_id: Uuid, step: u64, config: &'a RunnableConfig) -> Self
pub fn new(run_id: Uuid, step: u64, config: &'a RunnableConfig) -> Self
Create a new NodeCtx. Primarily used by the engine; exposed publicly
so node implementations in external crates can construct test contexts.
Sourcepub fn payload(&self) -> Option<&Value>
pub fn payload(&self) -> Option<&Value>
The Send payload accompanying this dispatch, if any. Returns None
when the node is invoked via Goto::Node or Goto::Multiple.
Sourcepub fn remaining_steps(&self) -> Option<u32>
pub fn remaining_steps(&self) -> Option<u32>
Number of supersteps remaining before the recursion limit fires.
None when running outside the engine (unit tests).
Sourcepub fn is_last_step(&self) -> bool
pub fn is_last_step(&self) -> bool
True if this is the final superstep — i.e. the engine will not run
another step after this one returns. Mirrors V1 IsLastStep.
Sourcepub fn write_custom(&self, kind: impl Into<String>, payload: Value)
pub fn write_custom(&self, kind: impl Into<String>, payload: Value)
Emit a Custom event on the run’s observer stream. Used by
StreamMode::Custom consumers to surface node-authored progress
signals (mirrors V1 StreamWriter).
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
True if the run was cancelled.