Skip to main content

aion/
lib.rs

1//! Transport-agnostic Aion workflow engine with durability, replay, timers, and supervision.
2//!
3//! The engine embeds beamr, loads `.aion` packages, owns workflow lifecycle and
4//! process residency, records and replays durable history, and exposes seams for
5//! activities, events, signals, queries, and server transports.
6//!
7//! # Example
8//!
9//! ```no_run
10//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
11//! use std::sync::Arc;
12//!
13//! use aion::EngineBuilder;
14//! use aion_store::{EventStore, InMemoryStore};
15//!
16//! let store: Arc<dyn EventStore> = Arc::new(InMemoryStore::default());
17//! let engine = EngineBuilder::new()
18//!     .store_arc(store)
19//!     .in_memory_visibility()
20//!     .build()
21//!     .await?;
22//! # let _ = engine;
23//! # Ok(())
24//! # }
25//! ```
26//!
27//! # Cargo features
28//!
29//! - `beamr_query_reentry_fixed` (off by default): compiles the
30//!   batch-orchestrator example e2e tests (`tests/example_query_reentry.rs`)
31//!   that drive live queries through the Gleam SDK's query pump while a
32//!   parent is parked in `child.await`. The engine-side query protocol is
33//!   fully functional, but the example's child-result decode path hits
34//!   beamr 0.4.9 VM gaps in `gleam_json`/`gleam_stdlib`; enable the feature
35//!   once the upstream beamr fixes land and the pin is bumped.
36
37#![deny(unsafe_code)]
38
39/// Activity dispatch bridge and error propagation helpers.
40pub mod activity;
41/// Child-workflow spawn support.
42pub mod child;
43/// Durable command recording, replay, and recovery support.
44pub mod durability;
45/// Engine builder, runtime APIs, and delegated seams.
46pub mod engine;
47/// Handle type exposed by embedded engine seams.
48pub mod engine_seam;
49/// Engine and routing error types.
50pub mod error;
51/// Workflow lifecycle start, transition, visibility, and termination helpers.
52pub mod lifecycle;
53/// `.aion` package loading into runtime modules.
54pub mod loader;
55/// Live event publication: publish-after-commit store wrapper and publisher.
56pub mod publish;
57/// Query dispatch services and mailbox support.
58pub mod query;
59/// Active workflow registry and handle residency tracking.
60pub mod registry;
61/// BEAM runtime configuration, handles, NIFs, and workflow process support.
62pub mod runtime;
63/// Schedule evaluation and cron parsing support.
64pub mod schedule;
65/// Signal routing and resume handoff support.
66pub mod signal;
67/// Supervision tree models for engines, workflow types, and workflow instances.
68pub mod supervision;
69/// Timer creation, recovery, and wake-up services.
70pub mod time;
71
72pub use activity::{
73    ActivityDispatcher, dispatch_activity, propagate_activity_outcome, surface_activity_error,
74};
75pub use durability::ActiveWorkflowRecoverySeamImpl;
76pub use engine::{
77    DeferredEventPublisher, DeferredQueryService, DeferredSignalRouter, DelegatedSeams, Engine,
78    EngineBuilder, EventFamily, EventFilter, EventPublisher, EventStreamLagged, QueryService,
79    SignalRouter,
80};
81pub use engine_seam::EngineHandle;
82pub use error::{EngineError, PinHolder, SignalRouterError};
83pub use loader::{LoadOutcome, LoadedWorkflow, WorkflowCatalog, WorkflowVersionInfo};
84pub use publish::{BroadcastEventPublisher, PublishError, PublishingEventStore};
85pub use query::{ConcreteQueryService, QueryError};
86pub use registry::{
87    CompletionNotifier, HandleResidency, Registry, Residency, TerminalOutcome, WorkflowHandle,
88    WorkflowHandleParts,
89};
90pub use runtime::{Pid, RuntimeConfig, RuntimeHandle, RuntimeInput, SignalDeliveryConfig};
91pub use schedule::{ScheduleError, next_fire_time, parse_cron_expression};
92pub use supervision::{
93    EngineSupervisorId, SupervisionTree, TypeSupervisorId, TypeSupervisorNode, WorkflowNode,
94};