Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime<S: State + Default> {
    pub previous: Option<Value>,
    pub checkpointer: Option<Arc<dyn CheckpointSaver>>,
    pub store: Option<Arc<dyn Store>>,
    pub core: Runtime<S>,
}
Expand description

Runtime context for functional API workflows

Provides access to previous execution state, checkpointing, and storage during workflow execution. This type extends CoreRuntime with functional-API-specific features like previous value access.

§Type Parameters

§Fields

  • previous - Previous execution return value (for accumulation patterns)
  • checkpointer - Checkpoint saver for state persistence
  • store - Cross-thread persistent key-value store
  • core - Underlying core runtime for advanced use cases

§Examples

§Accessing previous state

use juncture_core::func::Runtime;

async fn accumulating_workflow(
    state: CowState<MyState>,
    runtime: &CoreRuntime<MyState>,
) -> Result<MyStateUpdate, JunctureError> {
    // Access the functional runtime
    let func_runtime = Runtime::from_core(runtime);

    // Get the previous return value
    if let Some(previous) = &func_runtime.previous {
        let prev_output: Output = serde_json::from_value(previous.clone())
            .map_err(|e| JunctureError::execution(format!("Failed to deserialize previous: {}", e)))?;
        // Use previous value for accumulation
    }

    Ok(MyStateUpdate::default())
}

§Using the store

use juncture_core::func::Runtime;

async fn workflow_with_store(
    state: CowState<MyState>,
    runtime: &CoreRuntime<MyState>,
) -> Result<MyStateUpdate, JunctureError> {
    let func_runtime = Runtime::from_core(runtime);

    if let Some(store) = &func_runtime.store {
        store.put("key", serde_json::json!("value")).await?;
    }

    Ok(MyStateUpdate::default())
}

Fields§

§previous: Option<Value>

Previous execution return value (for accumulation patterns)

When resuming from a checkpoint, this contains the return value from the previous execution. For first-time execution, this is None.

§checkpointer: Option<Arc<dyn CheckpointSaver>>

Checkpoint saver for state persistence

When set, the workflow can save and restore intermediate state.

§store: Option<Arc<dyn Store>>

Cross-thread persistent key-value store

Provides durable storage that survives across workflow executions.

§core: Runtime<S>

Underlying core runtime

Provides access to advanced runtime features like heartbeat, execution metadata, and streaming.

Implementations§

Source§

impl<S: State + Default> Runtime<S>

Source

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

Create a new runtime with minimal configuration

Source

pub fn from_core(core: &CoreRuntime<S>) -> Self

Create a functional runtime from a core runtime

This extracts functional-API-specific context from the core runtime, allowing entrypoint functions to access features like previous values.

Source

pub fn from_entrypoint_config(config: &EntrypointConfig) -> Self
where S: Default,

Create a runtime from an entrypoint configuration

Source

pub fn with_previous(self, previous: Value) -> Self

Set the previous execution value

Source

pub fn with_checkpointer(self, checkpointer: Arc<dyn CheckpointSaver>) -> Self

Set the checkpointer

Source

pub fn with_store(self, store: Arc<dyn Store>) -> Self

Set the store

Source

pub fn with_core(self, core: CoreRuntime<S>) -> Self

Set the core runtime

Trait Implementations§

Source§

impl<S: Clone + State + Default> Clone for Runtime<S>

Source§

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

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<S: State + Default + Debug> Debug for Runtime<S>

Source§

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

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

impl<S: State + Default> Default for Runtime<S>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<S> !RefUnwindSafe for Runtime<S>

§

impl<S> !UnwindSafe for Runtime<S>

§

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

§

impl<S> Send for Runtime<S>

§

impl<S> Sync for Runtime<S>

§

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

§

impl<S> UnsafeUnpin for Runtime<S>
where S: 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