pub struct PhlowRuntime { /* private fields */ }Expand description
Prepared runtime that can execute an in-memory pipeline.
Implementations§
Source§impl PhlowRuntime
impl PhlowRuntime
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new runtime with default settings.
This sets var_main to a default value so non-main pipelines auto-start.
Sourcepub fn with_settings(settings: Settings) -> Self
pub fn with_settings(settings: Settings) -> Self
Create a new runtime using explicit settings.
Sourcepub fn set_pipeline(&mut self, pipeline: Value) -> &mut Self
pub fn set_pipeline(&mut self, pipeline: Value) -> &mut Self
Set the pipeline to be executed.
This clears any prepared runtime state.
Sourcepub fn set_context(&mut self, context: Context) -> &mut Self
pub fn set_context(&mut self, context: Context) -> &mut Self
Set the execution context.
This clears any prepared runtime state.
Sourcepub fn set_settings(&mut self, settings: Settings) -> &mut Self
pub fn set_settings(&mut self, settings: Settings) -> &mut Self
Replace the runtime settings.
This clears any prepared runtime state.
Sourcepub fn set_base_path<P: Into<PathBuf>>(&mut self, base_path: P) -> &mut Self
pub fn set_base_path<P: Into<PathBuf>>(&mut self, base_path: P) -> &mut Self
Set the base path used for resolving local module paths.
This clears any prepared runtime state.
Sourcepub fn set_dispatch(&mut self, dispatch: Dispatch) -> &mut Self
pub fn set_dispatch(&mut self, dispatch: Dispatch) -> &mut Self
Provide a custom tracing dispatch instead of initializing OpenTelemetry.
This clears any prepared runtime state.
Sourcepub fn set_module<S: Into<String>>(
&mut self,
name: S,
module: PhlowModule,
) -> &mut Self
pub fn set_module<S: Into<String>>( &mut self, name: S, module: PhlowModule, ) -> &mut Self
Register an inline module by name.
The module must be declared in the pipeline modules list.
The handler runs asynchronously inside the runtime.
This clears any prepared runtime state.
Sourcepub fn settings_mut(&mut self) -> &mut Settings
pub fn settings_mut(&mut self) -> &mut Settings
Mutable access to settings.
This clears any prepared runtime state.
Sourcepub async fn build(&mut self) -> Result<(), PhlowRuntimeError>
pub async fn build(&mut self) -> Result<(), PhlowRuntimeError>
Build and prepare the runtime (load modules, tracing, and start loop).
Calling this multiple times is safe; it is a no-op if already prepared.
Sourcepub async fn run(&mut self) -> Result<Value, PhlowRuntimeError>
pub async fn run(&mut self) -> Result<Value, PhlowRuntimeError>
Execute the pipeline and return its result.
This can be called multiple times after build. When the
pipeline cannot auto-start (for example, a main module is present and
var_main is not set), this returns Value::Undefined and shuts down
the prepared runtime. For normal execution, call shutdown
when you are done to release resources.
Sourcepub async fn shutdown(&mut self) -> Result<(), PhlowRuntimeError>
pub async fn shutdown(&mut self) -> Result<(), PhlowRuntimeError>
Shut down the prepared runtime and release resources.
Call this when you are done reusing the runtime to close channels, wait for the runtime task, and flush tracing providers.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PhlowRuntime
impl !RefUnwindSafe for PhlowRuntime
impl Send for PhlowRuntime
impl Sync for PhlowRuntime
impl Unpin for PhlowRuntime
impl UnsafeUnpin for PhlowRuntime
impl !UnwindSafe for PhlowRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request