Skip to main content

Runtime

Struct Runtime 

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

Immutable user-provided context

§store: Option<Arc<dyn Store>>

Optional cross-thread persistent storage

§heartbeat: Heartbeat

Heartbeat 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>

Source

pub fn new() -> Self
where C: Default,

Create a new runtime with minimal configuration

Source

pub fn with_context(context: C) -> Self

Create a new runtime with custom context

Source

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.

Source

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.

Source

pub const fn heartbeat(&self) -> &Heartbeat

Access the heartbeat for sending periodic alive signals

Long-running nodes should call heartbeat.ping() periodically to prevent false idle timeout detection.

Trait Implementations§

Source§

impl<C: Clone + Clone + Send + Sync + 'static> Clone for Runtime<C>

Source§

fn clone(&self) -> Runtime<C>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C> Debug for Runtime<C>
where C: Debug + Clone + Send + Sync + 'static,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Runtime<()>
where (): Debug,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C = ()> !RefUnwindSafe for Runtime<C>

§

impl<C = ()> !UnwindSafe for Runtime<C>

§

impl<C> Freeze for Runtime<C>
where C: Freeze,

§

impl<C> Send for Runtime<C>

§

impl<C> Sync for Runtime<C>

§

impl<C> Unpin for Runtime<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for Runtime<C>
where C: UnsafeUnpin,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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