pub trait Operation: Send + Sync {
// Required methods
fn kind(&self) -> &str;
fn execute(
&self,
) -> Pin<Box<dyn Future<Output = Result<Value, EngineError>> + Send + '_>>;
// Provided method
fn input(&self) -> Option<Value> { ... }
}Expand description
A user-defined operation that integrates into the workflow step lifecycle.
Implement this trait for custom integrations (GitLab, Gmail, Slack, etc.)
that need full step tracking when executed via
WorkflowContext::operation().
§Contract
kind()returns a short, lowercase identifier stored asStepKind::Customin the database (e.g."gitlab","gmail","slack").execute()performs the operation and returns a JSONValueon success. The engine persists this as the step output.
§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 SendSlackMessage {
channel: String,
text: String,
}
impl Operation for SendSlackMessage {
fn kind(&self) -> &str { "slack" }
fn execute(&self) -> Pin<Box<dyn Future<Output = Result<Value, EngineError>> + Send + '_>> {
Box::pin(async move {
// Post to Slack API ...
Ok(json!({"ok": true, "ts": "1234567890.123456"}))
})
}
}Required Methods§
Sourcefn kind(&self) -> &str
fn kind(&self) -> &str
A short, lowercase identifier for this operation type.
Stored as StepKind::Custom(kind)
in the database. Examples: "gitlab", "gmail", "slack".
Sourcefn execute(
&self,
) -> Pin<Box<dyn Future<Output = Result<Value, EngineError>> + Send + '_>>
fn execute( &self, ) -> Pin<Box<dyn Future<Output = Result<Value, EngineError>> + Send + '_>>
Execute the operation and return the result as JSON.
The returned Value is persisted as the step output. On error,
the engine marks the step as Failed and records the error message.
§Errors
Return EngineError if the operation fails.