Skip to main content

FlowEngineBuilder

Struct FlowEngineBuilder 

Source
pub struct FlowEngineBuilder { /* private fields */ }
Expand description

Builder for constructing a FlowEngine.

Register action executors with .action() / .action_fallback(), foreach item sources with .item_provider(), gate resolvers with .gate_resolver(), and environment injection with .script_env_provider().

Implementations§

Source§

impl FlowEngineBuilder

Source

pub fn new() -> Self

Examples found in repository?
examples/stdout_event_sink.rs (line 49)
34fn main() {
35    let sink = StdoutEventSink;
36
37    sink.emit(&EngineEventData::new(
38        "run-001".into(),
39        EngineEvent::RunStarted {
40            workflow_name: "my-workflow".into(),
41        },
42    ));
43    sink.emit(&EngineEventData::new(
44        "run-001".into(),
45        EngineEvent::RunCompleted { succeeded: true },
46    ));
47
48    // Wire it into a FlowEngine (builder shown; engine not actually run here):
49    let _engine = FlowEngineBuilder::new()
50        .event_sink(Box::new(StdoutEventSink))
51        .build()
52        .expect("engine build failed");
53    println!("engine built with StdoutEventSink attached");
54}
Source

pub fn action(self, executor: Box<dyn ActionExecutor>) -> Self

Register a named executor. The executor’s name() is used as the lookup key.

Source

pub fn action_fallback( self, executor: Box<dyn ActionExecutor>, ) -> Result<Self, EngineError>

Register the fallback (catch-all) executor.

Returns Err if called more than once — only one fallback is allowed.

Source

pub fn item_provider<P: ItemProvider + 'static>(self, provider: P) -> Self

Register an item provider for foreach fan-outs.

Source

pub fn gate_resolver<R: GateResolver + 'static>(self, resolver: R) -> Self

Register a gate resolver for a specific gate type.

Source

pub fn script_env_provider(self, provider: Box<dyn ScriptEnvProvider>) -> Self

Set the script env provider. Defaults to NoOpScriptEnvProvider.

Source

pub fn workflow_dir(self, path: impl Into<PathBuf>) -> Self

Convenience: register a DirectoryWorkflowResolver rooted at path.

FlowEngine::validate() will read <path>/<name>.wf on each call workflow node it encounters. Re-reads on every call so hot-reload is preserved.

Source

pub fn workflow_resolver(self, resolver: Box<dyn WorkflowResolver>) -> Self

Set a custom WorkflowResolver for sub-workflow validation and cycle detection.

Overrides any previous .workflow_dir() call.

Source

pub fn event_sink(self, sink: Box<dyn EventSink>) -> Self

Register an event sink. Multiple calls register multiple sinks; events are emitted to all sinks in registration order.

Examples found in repository?
examples/stdout_event_sink.rs (line 50)
34fn main() {
35    let sink = StdoutEventSink;
36
37    sink.emit(&EngineEventData::new(
38        "run-001".into(),
39        EngineEvent::RunStarted {
40            workflow_name: "my-workflow".into(),
41        },
42    ));
43    sink.emit(&EngineEventData::new(
44        "run-001".into(),
45        EngineEvent::RunCompleted { succeeded: true },
46    ));
47
48    // Wire it into a FlowEngine (builder shown; engine not actually run here):
49    let _engine = FlowEngineBuilder::new()
50        .event_sink(Box::new(StdoutEventSink))
51        .build()
52        .expect("engine build failed");
53    println!("engine built with StdoutEventSink attached");
54}
Source

pub fn with_event_sinks(self, sinks: &Arc<[Arc<dyn EventSink>]>) -> Self

Register multiple event sinks from an existing Arc<[Arc<dyn EventSink>]>. Sinks are appended in slice order after any already registered.

Source

pub fn build(self) -> Result<FlowEngine, EngineError>

Consume the builder and produce a FlowEngine.

Examples found in repository?
examples/stdout_event_sink.rs (line 51)
34fn main() {
35    let sink = StdoutEventSink;
36
37    sink.emit(&EngineEventData::new(
38        "run-001".into(),
39        EngineEvent::RunStarted {
40            workflow_name: "my-workflow".into(),
41        },
42    ));
43    sink.emit(&EngineEventData::new(
44        "run-001".into(),
45        EngineEvent::RunCompleted { succeeded: true },
46    ));
47
48    // Wire it into a FlowEngine (builder shown; engine not actually run here):
49    let _engine = FlowEngineBuilder::new()
50        .event_sink(Box::new(StdoutEventSink))
51        .build()
52        .expect("engine build failed");
53    println!("engine built with StdoutEventSink attached");
54}

Trait Implementations§

Source§

impl Default for FlowEngineBuilder

Source§

fn default() -> Self

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

Auto Trait Implementations§

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