Skip to main content

RunnableCore

Trait RunnableCore 

Source
pub trait RunnableCore: Send + Sync {
    // Required method
    fn invoke<'a>(
        &'a self,
        input: Value,
        config: Option<&'a RunnableConfig>,
    ) -> BoxFuture<'a, Result<Value, SynwireError>>;

    // Provided methods
    fn batch<'a>(
        &'a self,
        inputs: Vec<Value>,
        config: Option<&'a RunnableConfig>,
    ) -> BoxFuture<'a, Result<Vec<Value>, SynwireError>> { ... }
    fn stream<'a>(
        &'a self,
        input: Value,
        config: Option<&'a RunnableConfig>,
    ) -> BoxFuture<'a, Result<BoxStream<'a, Result<Value, SynwireError>>, SynwireError>> { ... }
    fn name(&self) -> &str { ... }
}
Expand description

Core trait for all runnable components in a chain.

Uses serde_json::Value as the universal input/output type for composability between heterogeneous runnables.

§Default implementations

  • batch invokes sequentially over each input.
  • stream wraps invoke as a single-item stream.

§Lifetime parameter

All async methods share a single lifetime 'a that ties together &'a self and Option<&'a RunnableConfig>, ensuring the returned future can borrow both.

§Cancel safety

invoke and batch are not cancel-safe in general – the behaviour depends on the concrete implementation. Dropping batch mid-execution may leave earlier inputs processed but later inputs unprocessed. The BoxStream returned by stream can be safely dropped at any point.

Required Methods§

Source

fn invoke<'a>( &'a self, input: Value, config: Option<&'a RunnableConfig>, ) -> BoxFuture<'a, Result<Value, SynwireError>>

Invoke the runnable with a single input.

Provided Methods§

Source

fn batch<'a>( &'a self, inputs: Vec<Value>, config: Option<&'a RunnableConfig>, ) -> BoxFuture<'a, Result<Vec<Value>, SynwireError>>

Invoke on multiple inputs. Default implementation calls invoke sequentially for each input.

Source

fn stream<'a>( &'a self, input: Value, config: Option<&'a RunnableConfig>, ) -> BoxFuture<'a, Result<BoxStream<'a, Result<Value, SynwireError>>, SynwireError>>

Stream results. Default implementation wraps invoke as a single-item stream.

Source

fn name(&self) -> &str

Get the runnable’s name for debugging.

Implementors§