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
§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§
Sourcefn invoke<'a>(
&'a self,
input: Value,
config: Option<&'a RunnableConfig>,
) -> BoxFuture<'a, Result<Value, SynwireError>>
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§
Sourcefn batch<'a>(
&'a self,
inputs: Vec<Value>,
config: Option<&'a RunnableConfig>,
) -> BoxFuture<'a, Result<Vec<Value>, SynwireError>>
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.
Sourcefn stream<'a>(
&'a self,
input: Value,
config: Option<&'a RunnableConfig>,
) -> BoxFuture<'a, Result<BoxStream<'a, Result<Value, SynwireError>>, SynwireError>>
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.