Skip to main content

NodeCtx

Struct NodeCtx 

Source
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: Uuid

Correlation ID for this run.

§step: u64

Superstep counter (0-indexed).

§config: &'a RunnableConfig

The active runnable config (recursion_limit, observers, cancel_token, …).

Implementations§

Source§

impl<'a> NodeCtx<'a>

Source

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.

Source

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.

Source

pub fn remaining_steps(&self) -> Option<u32>

Number of supersteps remaining before the recursion limit fires. None when running outside the engine (unit tests).

Source

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.

Source

pub fn emit(&self, event: &Event)

Notify every observer in config.observers of an event.

Source

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).

Source

pub fn is_cancelled(&self) -> bool

True if the run was cancelled.

Source

pub fn observers(&self) -> &[Arc<dyn Observer>]

Convenience accessor for observers.

Auto Trait Implementations§

§

impl<'a> Freeze for NodeCtx<'a>

§

impl<'a> !RefUnwindSafe for NodeCtx<'a>

§

impl<'a> Send for NodeCtx<'a>

§

impl<'a> Sync for NodeCtx<'a>

§

impl<'a> Unpin for NodeCtx<'a>

§

impl<'a> UnsafeUnpin for NodeCtx<'a>

§

impl<'a> !UnwindSafe for NodeCtx<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more