Skip to main content

ironflow_engine/
lib.rs

1//! # ironflow-engine
2//!
3//! Workflow orchestration engine for **ironflow**.
4//!
5//! Workflows are defined as Rust-native handlers implementing
6//! [`WorkflowHandler`](handler::WorkflowHandler). Handlers receive a
7//! [`WorkflowContext`](context::WorkflowContext) and can chain step outputs,
8//! use native `if`/`else`/`match` for conditional branching, and execute
9//! steps in parallel.
10//!
11//! Handlers can be executed inline or enqueued for a background worker.
12//!
13//! ## Custom operations
14//!
15//! Implement [`Operation`](operation::Operation) to define custom step types
16//! (e.g. GitLab, Gmail, Slack) that integrate into the workflow lifecycle.
17//! Call [`WorkflowContext::operation()`](context::WorkflowContext::operation)
18//! inside a handler to execute them with full step tracking.
19//!
20//! # Example
21//!
22//! ```no_run
23//! use ironflow_engine::prelude::*;
24//! use std::future::Future;
25//! use std::pin::Pin;
26//!
27//! struct DeployWorkflow;
28//!
29//! impl WorkflowHandler for DeployWorkflow {
30//!     fn name(&self) -> &str { "deploy" }
31//!     fn execute<'a>(&'a self, ctx: &'a mut WorkflowContext) -> HandlerFuture<'a> {
32//!         Box::pin(async move {
33//!             let build = ctx.shell("build", ShellConfig::new("cargo build")).await?;
34//!             ctx.agent("review", AgentStepConfig::new(
35//!                 &format!("Review: {}", build.output["stdout"])
36//!             )).await?;
37//!             Ok(())
38//!         })
39//!     }
40//! }
41//! ```
42
43/// Engine version, compiled from `Cargo.toml` at build time.
44pub const VERSION: &str = env!("CARGO_PKG_VERSION");
45
46pub mod artifact;
47pub mod budget;
48pub mod config;
49pub mod context;
50mod control_flow;
51pub mod engine;
52pub mod error;
53pub mod executor;
54pub mod fsm;
55pub mod guard;
56pub mod handler;
57pub mod log_sender;
58pub mod notify;
59pub mod operation;
60pub mod retry_policy;
61pub mod run_creator;
62pub mod schedule;
63
64/// Convenience re-exports.
65pub mod prelude {
66    pub use crate::artifact::{ArtifactSink, ArtifactUpload, DirectArtifactSink};
67    pub use crate::budget::BudgetConfig;
68    pub use crate::config::{
69        AgentStepConfig, ApprovalConfig, DelayConfig, HttpConfig, ShellConfig, StepConfig,
70    };
71    pub use crate::context::WorkflowContext;
72    pub use crate::engine::{Engine, EnqueueOptions, WorkflowResult};
73    pub use crate::error::EngineError;
74    pub use crate::executor::StepResult;
75    pub use crate::fsm::{RunEvent, RunFsm, StepEvent, StepFsm};
76    pub use crate::guard::{WorkflowGuardConfig, WorkflowGuardState, WorkflowRejection};
77    pub use crate::handler::{HandlerFuture, WorkflowHandler};
78    pub use crate::notify::{
79        Event, EventPublisher, EventSubscriber, WebhookSubscriber, WorkflowEvent, WorkflowEventBus,
80    };
81    pub use crate::operation::{
82        NoopSecretResolver, Operation, OperationContext, SecretResolver, SecretValue,
83        TypedOperation,
84    };
85    pub use crate::run_creator::{CreateRunOpts, RunCreator};
86    pub use crate::schedule::CronSchedule;
87}