Expand description
WorkflowHandler trait — dynamic workflows with context chaining.
Implement this trait to define workflows where steps can reference
outputs from previous steps. The handler receives a WorkflowContext
that provides step execution methods with automatic persistence.
§Examples
use ironflow_engine::handler::WorkflowHandler;
use ironflow_engine::context::WorkflowContext;
use ironflow_engine::config::{ShellConfig, AgentStepConfig};
use ironflow_engine::error::EngineError;
use std::future::Future;
use std::pin::Pin;
struct DeployWorkflow;
impl WorkflowHandler for DeployWorkflow {
fn name(&self) -> &str {
"deploy"
}
fn execute<'a>(
&'a self,
ctx: &'a mut WorkflowContext,
) -> Pin<Box<dyn Future<Output = Result<(), EngineError>> + Send + 'a>> {
Box::pin(async move {
let build = ctx.shell("build", ShellConfig::new("cargo build --release")).await?;
let tests = ctx.shell("test", ShellConfig::new("cargo test")).await?;
let review = ctx.agent("review", AgentStepConfig::new(
&format!("Build:\n{}\nTests:\n{}\nReview.",
build.output["stdout"], tests.output["stdout"])
)).await?;
if review.output["value"].as_str().unwrap_or("").contains("LGTM") {
ctx.shell("deploy", ShellConfig::new("./deploy.sh")).await?;
}
Ok(())
})
}
}Structs§
- Workflow
Info - Metadata about a workflow, returned by
WorkflowHandler::describe.
Traits§
- Workflow
Handler - A dynamic workflow handler with context-aware step chaining.
Type Aliases§
- Handler
Future - Boxed future returned by
WorkflowHandler::execute.