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 hit
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//!   NOTE: the crate is now pinned to beamr 0.6.4. The gap this gate guards
38//!   against was identified on 0.4.9 and may have been fixed upstream, so the
39//!   gate needs re-validation against 0.6.4 and may now be stale.
40
41#![deny(unsafe_code)]
42
43/// Activity dispatch bridge and error propagation helpers.
44pub mod activity;
45/// Child-workflow spawn support.
46pub mod child;
47/// Durable command recording, replay, and recovery support.
48pub mod durability;
49/// Engine builder, runtime APIs, and delegated seams.
50pub mod engine;
51/// Handle type exposed by embedded engine seams.
52pub mod engine_seam;
53/// Engine and routing error types.
54pub mod error;
55/// Workflow lifecycle start, transition, visibility, and termination helpers.
56pub mod lifecycle;
57/// `.aion` package loading into runtime modules.
58pub mod loader;
59/// Live event publication: publish-after-commit store wrapper and publisher.
60pub mod publish;
61/// Query dispatch services and mailbox support.
62pub mod query;
63/// Active workflow registry and handle residency tracking.
64pub mod registry;
65/// BEAM runtime configuration, handles, NIFs, and workflow process support.
66pub mod runtime;
67/// Schedule evaluation and cron parsing support.
68pub mod schedule;
69/// Signal routing and resume handoff support.
70pub mod signal;
71/// Supervision tree models for engines, workflow types, and workflow instances.
72pub mod supervision;
73/// Timer creation, recovery, and wake-up services.
74pub mod time;
75
76pub use activity::{
77    ActivityDispatch, ActivityDispatcher, dispatch_activity, propagate_activity_outcome,
78    surface_activity_error,
79};
80pub use durability::ActiveWorkflowRecoverySeamImpl;
81pub use engine::{
82    DeferredEventPublisher, DeferredQueryService, DeferredSignalRouter, DelegatedSeams, Engine,
83    EngineBuilder, EventFamily, EventFilter, EventPublisher, EventStreamLagged, QueryService,
84    SignalRouter, schedule_coordinator_workflow_id,
85};
86pub use engine_seam::EngineHandle;
87pub use error::{EngineError, PinHolder, SignalRouterError};
88pub use loader::{LoadOutcome, LoadedWorkflow, WorkflowCatalog, WorkflowVersionInfo};
89pub use publish::{BroadcastEventPublisher, PublishError, PublishingEventStore};
90pub use query::{ConcreteQueryService, QueryError};
91pub use registry::{
92    CompletionNotifier, HandleResidency, Registry, Residency, TerminalOutcome, WorkflowHandle,
93    WorkflowHandleParts,
94};
95pub use runtime::{
96    PARKED_ACTIVITY_REASON, Pid, RuntimeConfig, RuntimeHandle, RuntimeInput, SignalDeliveryConfig,
97    is_parked_reason,
98};
99pub use schedule::{ScheduleError, next_fire_time, parse_cron_expression};
100pub use supervision::{
101    EngineSupervisorId, SupervisionTree, TypeSupervisorId, TypeSupervisorNode, WorkflowNode,
102};