pub struct NodeContext {
pub state: State,
pub config: ExecutionConfig,
pub step: usize,
/* private fields */
}Expand description
Context passed to nodes during execution
Fields§
§state: StateCurrent graph state (read-only view)
config: ExecutionConfigConfiguration for this execution
step: usizeCurrent step number
Implementations§
Source§impl NodeContext
impl NodeContext
Sourcepub fn new(state: State, config: ExecutionConfig, step: usize) -> Self
pub fn new(state: State, config: ExecutionConfig, step: usize) -> Self
Create a new node context
Sourcepub fn get_as<T: DeserializeOwned>(&self, key: &str) -> Option<T>
pub fn get_as<T: DeserializeOwned>(&self, key: &str) -> Option<T>
Get a value from state as a specific type
Sourcepub fn report_progress(&self)
pub fn report_progress(&self)
Report progress, resetting the idle timeout counter.
Nodes performing long-running work should call this periodically to prevent the idle timeout from firing. If no progress handle is attached (e.g., when no idle timeout is configured), this is a no-op.
§Example
ⓘ
async fn execute(&self, ctx: &NodeContext) -> Result<NodeOutput> {
for chunk in large_dataset.chunks(100) {
process(chunk).await;
ctx.report_progress(); // reset idle timeout
}
Ok(NodeOutput::new())
}Sourcepub fn set_progress_handle(&mut self, handle: ProgressHandle)
pub fn set_progress_handle(&mut self, handle: ProgressHandle)
Attach a progress handle for idle timeout tracking.
This is called by the executor before running a node with an idle timeout policy. Nodes do not need to call this directly.
Sourcepub fn progress_handle(&self) -> Option<&ProgressHandle>
pub fn progress_handle(&self) -> Option<&ProgressHandle>
Get a reference to the attached progress handle, if any.
Auto Trait Implementations§
impl Freeze for NodeContext
impl RefUnwindSafe for NodeContext
impl Send for NodeContext
impl Sync for NodeContext
impl Unpin for NodeContext
impl UnsafeUnpin for NodeContext
impl UnwindSafe 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
Mutably borrows from an owned value. Read more