pub trait WorkflowHandler: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn execute<'a>(&'a self, ctx: &'a mut WorkflowContext) -> HandlerFuture<'a>;
// Provided methods
fn version(&self) -> Option<&str> { ... }
fn category(&self) -> Option<&str> { ... }
fn input_schema(&self) -> Option<Value> { ... }
fn default_labels(&self) -> HashMap<String, String> { ... }
fn describe(&self) -> WorkflowInfo { ... }
}Expand description
A dynamic workflow handler with context-aware step chaining.
Implement this trait to define workflows where each step can use
the output of previous steps. Register handlers with
Engine::register and execute
them by name.
§Why Pin<Box<dyn Future>> instead of async fn?
The handler must be object-safe (dyn WorkflowHandler) to allow
registering different handler types in the engine’s registry.
Required Methods§
Sourcefn execute<'a>(&'a self, ctx: &'a mut WorkflowContext) -> HandlerFuture<'a>
fn execute<'a>(&'a self, ctx: &'a mut WorkflowContext) -> HandlerFuture<'a>
Execute the workflow with the given context.
The context provides shell,
http, and agent
methods that automatically persist each step.
§Errors
Return EngineError if any step fails. The engine will mark
the run as Failed and record the error.
Provided Methods§
Sourcefn version(&self) -> Option<&str>
fn version(&self) -> Option<&str>
Handler version string, used to trace which code version produced a run.
Override this to return a meaningful version (semver, git SHA, build
hash, etc.). The default is None.
Sourcefn category(&self) -> Option<&str>
fn category(&self) -> Option<&str>
Optional /-separated category path used to group workflows in the UI tree.
Return a value like "data/etl" to place the workflow under data → etl.
The default is None (uncategorized).
Validation (empty segments, leading or trailing /, //, whitespace
segments) is enforced at registration time by
Engine::register.
Sourcefn input_schema(&self) -> Option<Value>
fn input_schema(&self) -> Option<Value>
Return a JSON Schema describing the expected input payload.
When present, the dashboard renders a dynamic form from this schema
and the engine validates the payload before creating a run.
The default is None (no schema, free-form payload).
Sourcefn default_labels(&self) -> HashMap<String, String>
fn default_labels(&self) -> HashMap<String, String>
Labels automatically applied to every run of this workflow.
These are merged with any labels provided at run creation time. User-provided labels take precedence over defaults.
Sourcefn describe(&self) -> WorkflowInfo
fn describe(&self) -> WorkflowInfo
Return metadata about this workflow (description, source code).
Override this to provide a description and source code for the
dashboard UI. The default returns an empty description with no source
but propagates WorkflowHandler::category,
WorkflowHandler::version, WorkflowHandler::input_schema,
and WorkflowHandler::default_labels.