#[non_exhaustive]pub struct NodeContext {
pub node_id: String,
pub step: u64,
pub event_emitter: Arc<dyn EventEmitter>,
pub clock: Option<Arc<dyn Clock>>,
pub invocation_id: Option<String>,
}Expand description
Execution context passed to nodes during workflow execution.
Carries the node’s identity, current step, and communication channels for observability.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.node_id: StringUnique identifier for this node instance.
step: u64Current execution step number.
event_emitter: Arc<dyn EventEmitter>Channel for emitting events to the workflow’s event system.
clock: Option<Arc<dyn Clock>>Optional runtime clock for deterministic tests and replay.
invocation_id: Option<String>Optional invocation identifier attached to node events.
Implementations§
Source§impl NodeContext
impl NodeContext
Sourcepub fn new(
node_id: impl Into<String>,
step: u64,
event_emitter: Arc<dyn EventEmitter>,
) -> Self
pub fn new( node_id: impl Into<String>, step: u64, event_emitter: Arc<dyn EventEmitter>, ) -> Self
Construct a context with no clock or invocation metadata.
Sourcepub fn now_unix_ms(&self) -> Option<i64>
pub fn now_unix_ms(&self) -> Option<i64>
Current runtime clock timestamp in Unix milliseconds, if configured.
Sourcepub fn invocation_id(&self) -> Option<&str>
pub fn invocation_id(&self) -> Option<&str>
Invocation identifier, if configured.
Sourcepub fn emit(
&self,
scope: impl Into<String>,
message: impl Into<String>,
) -> Result<(), NodeContextError>
pub fn emit( &self, scope: impl Into<String>, message: impl Into<String>, ) -> Result<(), NodeContextError>
Emit a node-scoped event enriched with this context’s metadata.
Attaches invocation_id and now_unix_ms when available, making
emitted events traceable in the execution log.
Sourcepub fn emit_diagnostic(
&self,
scope: impl Into<String>,
message: impl Into<String>,
) -> Result<(), NodeContextError>
pub fn emit_diagnostic( &self, scope: impl Into<String>, message: impl Into<String>, ) -> Result<(), NodeContextError>
Emit a diagnostic event for general workflow telemetry.
Sourcepub fn emit_llm_chunk(
&self,
session_id: Option<String>,
stream_id: Option<String>,
chunk: impl Into<String>,
metadata: Option<FxHashMap<String, Value>>,
) -> Result<(), NodeContextError>
pub fn emit_llm_chunk( &self, session_id: Option<String>, stream_id: Option<String>, chunk: impl Into<String>, metadata: Option<FxHashMap<String, Value>>, ) -> Result<(), NodeContextError>
Emit an LLM streaming chunk event with optional metadata.
Trait Implementations§
Source§impl Clone for NodeContext
impl Clone for NodeContext
Auto Trait Implementations§
impl !RefUnwindSafe for NodeContext
impl !UnwindSafe for NodeContext
impl Freeze for NodeContext
impl Send for NodeContext
impl Sync for NodeContext
impl Unpin for NodeContext
impl UnsafeUnpin for NodeContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more