pub struct Runtime<C: Clone + Send + Sync + 'static = ()> {
pub context: C,
pub store: Option<Arc<dyn Store>>,
pub heartbeat: Heartbeat,
pub previous: Option<Value>,
pub execution_info: Option<ExecutionInfo>,
pub control: Option<RunControl>,
pub stream_writer: Option<Arc<dyn StreamWriterTrait>>,
}Expand description
Execution context for graph nodes
The runtime injects external dependencies into node execution, separate from the graph state. This includes context, storage, streaming, and execution metadata.
§Type Parameters
C- Context type (defaults to()for no context)
§Examples
use juncture_core::Runtime;
use std::sync::Arc;
// Simple runtime with no context
let runtime = Runtime::<()>::new();
// Runtime with custom context
struct MyContext { user_id: String }
let runtime = Runtime::with_context(MyContext { user_id: "123".to_string() });Fields§
§context: CImmutable user-provided context
store: Option<Arc<dyn Store>>Optional cross-thread persistent storage
heartbeat: HeartbeatHeartbeat mechanism for long-running nodes
previous: Option<Value>Previous execution return value (Functional API)
execution_info: Option<ExecutionInfo>Execution metadata (checkpoint, task, thread info)
control: Option<RunControl>Collaborative drain control for graceful shutdown
stream_writer: Option<Arc<dyn StreamWriterTrait>>Custom stream event emitter.
When set, nodes can emit custom stream data through this writer
regardless of the state type. The writer is type-erased via
StreamWriterTrait because Runtime<C> cannot directly hold
the state-parameterized StreamWriter<S>.
Implementations§
Source§impl<C: Clone + Send + Sync + 'static> Runtime<C>
impl<C: Clone + Send + Sync + 'static> Runtime<C>
Sourcepub fn with_context(context: C) -> Self
pub fn with_context(context: C) -> Self
Create a new runtime with custom context
Sourcepub fn set_execution_info(&mut self, info: ExecutionInfo)
pub fn set_execution_info(&mut self, info: ExecutionInfo)
Set the execution info for this runtime
Provides the runtime with execution metadata including step tracking and recursion limit, enabling nodes to query managed values.
Sourcepub fn managed_values(&self) -> ManagedValues
pub fn managed_values(&self) -> ManagedValues
Get the managed values for this runtime
Returns information about recursion limits and remaining steps. Nodes can use this to adapt behavior based on remaining step budget, e.g., generating summaries instead of continuing when steps are low.