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
impl FlowEngineBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
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}Sourcepub fn action(self, executor: Box<dyn ActionExecutor>) -> Self
pub fn action(self, executor: Box<dyn ActionExecutor>) -> Self
Register a named executor. The executor’s name() is used as the lookup key.
Sourcepub fn action_fallback(
self,
executor: Box<dyn ActionExecutor>,
) -> Result<Self, EngineError>
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.
Sourcepub fn item_provider<P: ItemProvider + 'static>(self, provider: P) -> Self
pub fn item_provider<P: ItemProvider + 'static>(self, provider: P) -> Self
Register an item provider for foreach fan-outs.
Sourcepub fn gate_resolver<R: GateResolver + 'static>(self, resolver: R) -> Self
pub fn gate_resolver<R: GateResolver + 'static>(self, resolver: R) -> Self
Register a gate resolver for a specific gate type.
Sourcepub fn script_env_provider(self, provider: Box<dyn ScriptEnvProvider>) -> Self
pub fn script_env_provider(self, provider: Box<dyn ScriptEnvProvider>) -> Self
Set the script env provider. Defaults to NoOpScriptEnvProvider.
Sourcepub fn workflow_dir(self, path: impl Into<PathBuf>) -> Self
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.
Sourcepub fn workflow_resolver(self, resolver: Box<dyn WorkflowResolver>) -> Self
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.
Sourcepub fn event_sink(self, sink: Box<dyn EventSink>) -> Self
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?
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}Sourcepub fn with_event_sinks(self, sinks: &Arc<[Arc<dyn EventSink>]>) -> Self
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.
Sourcepub fn build(self) -> Result<FlowEngine, EngineError>
pub fn build(self) -> Result<FlowEngine, EngineError>
Consume the builder and produce a FlowEngine.
Examples found in repository?
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}