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//! ## Testing handlers
21//!
22//! [`TestEngine`](testing::TestEngine) runs a handler against an in-memory
23//! store with mocked shell, HTTP, agent and approval steps, so a handler's
24//! logic can be asserted without a server, a worker or a real process.
25//!
26//! # Example
27//!
28//! ```no_run
29//! use ironflow_engine::prelude::*;
30//! use std::future::Future;
31//! use std::pin::Pin;
32//!
33//! struct DeployWorkflow;
34//!
35//! impl WorkflowHandler for DeployWorkflow {
36//! fn name(&self) -> &str { "deploy" }
37//! fn execute<'a>(&'a self, ctx: &'a mut WorkflowContext) -> HandlerFuture<'a> {
38//! Box::pin(async move {
39//! let build = ctx.shell("build", ShellConfig::new("cargo build")).await?;
40//! ctx.agent("review", AgentStepConfig::new(
41//! &format!("Review: {}", build.output["stdout"])
42//! )).await?;
43//! Ok(())
44//! })
45//! }
46//! }
47//! ```
48
49/// Engine version, compiled from `Cargo.toml` at build time.
50pub const VERSION: &str = env!("CARGO_PKG_VERSION");
51
52pub mod artifact;
53pub mod budget;
54pub mod config;
55pub mod context;
56pub mod engine;
57pub mod error;
58pub mod escalation;
59pub mod executor;
60pub mod expression;
61pub mod fsm;
62pub mod guard;
63pub mod handler;
64pub mod log_sender;
65pub mod notify;
66pub mod operation;
67pub mod plan;
68pub mod retry_policy;
69pub mod run_creator;
70pub mod schedule;
71pub mod testing;
72
73/// Convenience re-exports.
74pub mod prelude {
75 pub use crate::artifact::{ArtifactSink, ArtifactUpload, DirectArtifactSink};
76 pub use crate::budget::BudgetConfig;
77 pub use crate::config::{
78 AgentStepConfig, ApprovalConfig, ApprovalRule, DelayConfig, EscalationPolicy, HttpConfig,
79 NotificationTarget, ShellConfig, StepConfig,
80 };
81 pub use crate::context::WorkflowContext;
82 pub use crate::engine::{Engine, EnqueueOptions, WorkflowResult};
83 pub use crate::error::EngineError;
84 pub use crate::executor::StepResult;
85 pub use crate::expression::Expression;
86 pub use crate::fsm::{RunEvent, RunFsm, StepEvent, StepFsm};
87 pub use crate::guard::{WorkflowGuardConfig, WorkflowGuardState, WorkflowRejection};
88 pub use crate::handler::{HandlerFuture, WorkflowHandler};
89 pub use crate::notify::{
90 Event, EventPublisher, EventSubscriber, WebhookSubscriber, WorkflowEvent, WorkflowEventBus,
91 };
92 pub use crate::operation::{
93 NoopSecretResolver, Operation, OperationContext, SecretResolver, SecretValue,
94 TypedOperation,
95 };
96 pub use crate::plan::{ConditionResult, ExecutionPlan, PlanOptions, PlannedStep};
97 pub use crate::run_creator::{CreateRunOpts, RunCreator};
98 pub use crate::schedule::CronSchedule;
99}