Skip to main content

Module operation

Module operation 

Source
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

  1. Implement Operation on your type.
  2. Call WorkflowContext::operation() inside a WorkflowHandler.
  3. 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.