Expand description
Operation trait — user-defined step operations.
Implement this trait to create custom step types that integrate into the workflow lifecycle. Common use cases include API clients (GitLab, Gmail, Slack) that need full step tracking (persistence, duration, error handling).
§How it works
- Implement
Operationon your type. - Call
WorkflowContext::operation()inside aWorkflowHandler. - The engine handles the full step lifecycle: create step record, transition to Running, execute, persist output/duration, mark Completed or Failed.
§Examples
use ironflow_engine::operation::Operation;
use ironflow_engine::error::EngineError;
use serde_json::{Value, json};
use std::future::Future;
use std::pin::Pin;
struct CreateGitlabIssue {
project_id: u64,
title: String,
}
impl Operation for CreateGitlabIssue {
fn kind(&self) -> &str {
"gitlab"
}
fn execute(&self) -> Pin<Box<dyn Future<Output = Result<Value, EngineError>> + Send + '_>> {
Box::pin(async move {
// Call the GitLab API here (e.g. via the `gitlab` crate).
Ok(json!({"issue_id": 42, "url": "https://gitlab.com/issues/42"}))
})
}
}Traits§
- Operation
- A user-defined operation that integrates into the workflow step lifecycle.