Skip to main content

Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }
Expand description

Live embedded workflow engine assembled by crate::EngineBuilder.

Implementations§

Source§

impl Engine

Source

pub fn store(&self) -> Arc<dyn EventStore>

Event store used by lifecycle and delegated AD/AT operations.

Source

pub fn visibility_store(&self) -> Arc<dyn VisibilityStore>

Visibility store used for workflow summary projections.

Source

pub fn runtime(&self) -> &RuntimeHandle

Runtime boundary assembled for this engine.

Source

pub fn workflow_catalog(&self) -> &Arc<WorkflowCatalog>

Shared workflow package catalog: loaded versions and routing.

Source

pub fn registry(&self) -> &Registry

Active execution registry.

Source

pub fn supervision(&self) -> &SupervisionTree

Supervision tree snapshot/model.

Source

pub const fn delegated(&self) -> &DelegatedSeams

Delegated signal/query/subscribe seams installed for AT/AD integration.

Source

pub fn signal_handoff(&self) -> Arc<SignalResumeHandoff>

Shared in-memory handoff for already-recorded non-resident signals.

Source

pub async fn start_workflow( &self, workflow_type: &str, input: Payload, search_attributes: HashMap<String, SearchAttributeValue>, ) -> Result<WorkflowHandle, EngineError>

Start a loaded workflow type as a new BEAM process.

search_attributes are validated against the engine’s configured SearchAttributeSchema and recorded atomically with the WorkflowStarted event, so visibility metadata can never be lost to a crash between start and a later attribute update.

§Errors

Returns EngineError::ShuttingDown after shutdown begins, and EngineError::Durability when a search attribute is unregistered or mistyped (nothing is appended and no process is spawned). Otherwise delegates to the start lifecycle transition and returns its typed errors.

Source

pub fn resume_workflow( &self, id: &WorkflowId, run: &RunId, ) -> Result<WorkflowHandle, EngineError>

Resume a suspended workflow run and flush deferred signals through its mailbox.

§Errors

Returns EngineError::WorkflowNotFound when the (workflow, run) pair is absent, or registry errors from the residency transition. Deferred delivery failures are logged and dropped because signals are already durable.

Source

pub async fn cancel( &self, id: &WorkflowId, run: &RunId, reason: impl Into<String>, ) -> Result<(), EngineError>

Cancel a live workflow run by killing its runtime process.

§Errors

Returns EngineError::ShuttingDown after shutdown begins, and EngineError::WorkflowNotFound when the (workflow, run) pair is not live. Other typed errors come from the cancel transition.

Source

pub async fn continue_as_new( &self, id: &WorkflowId, run: &RunId, input: Payload, workflow_type: Option<String>, ) -> Result<WorkflowHandle, EngineError>

Continue a live workflow run as a new run under the same workflow id.

§Errors

Returns EngineError::ShuttingDown after shutdown begins, and EngineError::WorkflowNotFound when the (workflow, run) pair is not live. Other typed errors come from the continue-as-new transition.

Source

pub async fn result( &self, id: &WorkflowId, run: &RunId, ) -> Result<Result<Payload, WorkflowError>, EngineError>

Await a workflow run’s terminal result.

Already-terminal histories return immediately. Live workflows await their completion notifier. Unknown workflow/run pairs return not found.

§Errors

Returns store, registry, or runtime channel errors as typed EngineError variants, or EngineError::WorkflowNotFound when no live handle or terminal history exists for the requested pair.

Source

pub async fn list_workflows( &self, filter: WorkflowFilter, ) -> Result<Vec<WorkflowSummary>, EngineError>

List live and terminal workflow summaries matching filter.

Store projections are authoritative; live registry entries are projected from durable history before being merged and deduplicated.

§Errors

Returns typed store or registry errors when visibility data cannot be read.

Source

pub fn shutdown(&self) -> Result<(), EngineError>

Gracefully stop accepting new starts and shut down the embedded runtime.

§Errors

Returns registry poison or runtime shutdown failures as typed errors.

Source§

impl Engine

Source

pub const fn schedule_coordinator_workflow_id(&self) -> &WorkflowId

Workflow history used for durable schedule events and timer ownership.

Source

pub async fn create_schedule( &self, config: ScheduleConfig, ) -> Result<ScheduleId, EngineError>

Create a durable schedule and arm its first timer.

§Errors

Returns shutdown, durability, schedule projection, or timer arming errors.

Source

pub async fn update_schedule( &self, schedule_id: &ScheduleId, config: ScheduleConfig, ) -> Result<(), EngineError>

Update an existing schedule’s configuration and re-arm it.

§Errors

Returns EngineError::ShuttingDown after shutdown begins, EngineError::ScheduleNotFound for absent/deleted schedules, or typed durability, projection, and timer errors.

Source

pub async fn pause_schedule( &self, schedule_id: &ScheduleId, ) -> Result<(), EngineError>

Pause an existing schedule.

§Errors

Returns EngineError::ShuttingDown after shutdown begins, EngineError::ScheduleNotFound for absent/deleted schedules, or typed durability and projection errors.

Source

pub async fn resume_schedule( &self, schedule_id: &ScheduleId, ) -> Result<(), EngineError>

Resume an existing schedule and re-arm it.

§Errors

Returns EngineError::ShuttingDown after shutdown begins, EngineError::ScheduleNotFound for absent/deleted schedules, or typed durability, projection, and timer errors.

Source

pub async fn delete_schedule( &self, schedule_id: &ScheduleId, ) -> Result<(), EngineError>

Delete an existing schedule so it is no longer listed or armed.

§Errors

Returns EngineError::ShuttingDown after shutdown begins, EngineError::ScheduleNotFound for absent/deleted schedules, or typed durability and projection errors.

Source

pub async fn list_schedules(&self) -> Result<Vec<ScheduleState>, EngineError>

List all non-deleted schedules from projected state.

§Errors

Currently returns only infallible projected state, wrapped for API consistency.

Source

pub async fn describe_schedule( &self, schedule_id: &ScheduleId, ) -> Result<ScheduleState, EngineError>

Describe one non-deleted schedule.

§Errors

Returns EngineError::ScheduleNotFound for absent or deleted schedules.

Source

pub async fn handle_schedule_timer_fired( &self, schedule_id: &ScheduleId, fire_at: DateTime<Utc>, ) -> Result<TimerEvaluationOutcome, EngineError>

Handles a fired durable schedule timer through the schedule evaluator.

§Errors

Returns schedule evaluator or shutdown errors.

Source

pub async fn recover_schedules_on_startup( &self, now: DateTime<Utc>, ) -> Result<(), EngineError>

Rebuilds schedule state from durable coordinator history and re-arms active schedules.

§Errors

Returns schedule projection, catch-up, timer, or workflow-start errors.

Source§

impl Engine

Source

pub async fn signal( &self, id: &WorkflowId, run: &RunId, name: impl Into<String>, payload: Payload, ) -> Result<(), EngineError>

Send a signal to a live workflow run through the AT routing seam.

§Errors

Returns EngineError::WorkflowNotFound when the (workflow, run) pair is unknown, SignalRouterError::Terminal when it is durably terminal, or other typed errors from the configured signal seam.

Source

pub async fn query( &self, id: &WorkflowId, run: &RunId, name: impl Into<String>, ) -> Result<Payload, EngineError>

Dispatch a read-only query to a live workflow run through the AT seam.

§Errors

Returns EngineError::Query with crate::query::QueryError::NotRunning when the (workflow, run) pair is durably terminal, EngineError::WorkflowNotFound when it is unknown, and other typed errors from the configured query seam.

Source

pub fn subscribe( &self, filter: EventFilter, ) -> BoxStream<'static, Result<Event, EventStreamLagged>>

Subscribe to the live event stream through the AD/AT publisher seam.

A subscriber that falls behind receives one Err(EventStreamLagged) item with the skipped count and then continues with subsequent events.

Source§

impl Engine

Source

pub async fn load_package( &self, source: impl Into<WorkflowPackageSource>, ) -> Result<LoadOutcome, EngineError>

Loads a validated package into the running engine and atomically routes its workflow type’s new dispatches to it.

Every start that resolved before the route flip completes on the version it resolved (loads never unregister anything); every start after this call returns resolves the new version. Re-loading an already-loaded hash is idempotent (nothing registers, freshly_loaded = false) but still re-points the route at it — re-deploying a previously rolled-back version must take effect (route_changed reports whether it did).

A successful load is persisted to the store (archive bytes plus, atomically, the route pointer) so the deploy survives a restart: startup reloads every persisted package before recovery resolves any run’s recorded pinned version. Idempotent re-loads re-persist — re-deploying is a routing intent and the durable pointer must mirror it.

§Errors

Returns EngineError::ShuttingDown once shutdown begins, EngineError::Load for archive, collision, registration, or entry-verification failures, and EngineError::ManifestMismatch when an idempotent re-load presents the resident content hash with a different manifest. On those failures the catalog is untouched: routing, loaded versions, and in-flight dispatches are unaffected. Returns EngineError::Store when the load committed but persistence failed — the version is live in THIS process yet would not survive a restart, so the deploy must not be reported applied; re-sending the same archive is idempotent and retries persistence.

Source

pub fn list_workflow_versions( &self, ) -> Result<Vec<WorkflowVersionInfo>, EngineError>

Lists every loaded workflow version with its routing flag, sorted by (workflow_type, loaded_at).

§Errors

Returns EngineError::CatalogPoisoned when the catalog lock is poisoned.

Source

pub async fn route_workflow_version( &self, workflow_type: &str, version: &ContentHash, ) -> Result<(), EngineError>

Re-points routing for workflow_type at an already-loaded version (rollback / roll-forward). Atomic and idempotent.

The pointer is persisted so the re-point survives a restart; startup restores persisted pointers after reloading persisted packages.

§Errors

Returns EngineError::ShuttingDown once shutdown begins, EngineError::UnknownVersion naming the loaded set when (type, version) is not loaded — routing to a never-loaded hash is impossible — and EngineError::Store when the in-memory re-point committed but the durable pointer could not be written (retrying the same re-point is idempotent and re-attempts persistence).

Source

pub async fn unload_workflow_version( &self, workflow_type: &str, version: &ContentHash, ) -> Result<(), EngineError>

Unloads a workflow version after verifying nothing pins it (D2).

Refusal conditions, each typed and naming what pins the version: route-inactive is required (the route-active version of a type can never be unloaded), no in-flight start may pin it, no live registry handle may run on it, and no recoverable instance in the store — including a recorded-but-never-started child — may be pinned to it.

The engine owns the mechanism; the embedding platform owns when to unload. There is no automatic garbage collection.

Unload deletes the persisted deploy artifact too (a no-op for versions loaded from operator files, which were never persisted), so an unloaded version does not resurrect at the next restart.

§Errors

Returns EngineError::ShuttingDown once shutdown begins, EngineError::UnknownVersion when (type, version) is not loaded, EngineError::RouteActive when the version is route-active, EngineError::VersionPinned naming the concrete pin holder (with the catalog restored untouched), EngineError::Store when the persisted artifact could not be deleted (the catalog is restored and the unload did not happen), and EngineError::Runtime when module unregistration fails after the catalog commit.

Trait Implementations§

Source§

impl EngineHandle for Engine

Source§

fn resolve_workflow( &self, workflow_id: &WorkflowId, ) -> Result<WorkflowResidency, EngineSeamError>

Resolves a workflow identifier to its current residency state. Read more
Source§

fn deliver_workflow_message( &self, process: WorkflowProcessHandle, message: WorkflowMailboxMessage, ) -> Result<(), EngineSeamError>

Delivers a message to a resident workflow process mailbox. Read more
Source§

fn spawn_child_workflow( &self, request: ChildWorkflowSpawnRequest, ) -> Result<ChildWorkflowSpawnResult, EngineSeamError>

Requests AE to spawn a child workflow execution linked to the parent process. Read more
Source§

fn terminate_linked_child_workflow( &self, parent_workflow_id: &WorkflowId, child_process: WorkflowProcessHandle, correlation: u64, ) -> Result<(), EngineSeamError>

Terminates a linked child workflow process through AE’s process-link boundary. Read more
Source§

fn terminate_linked_activity( &self, parent_workflow_id: &WorkflowId, activity_process: Pid, correlation: u64, ) -> Result<(), EngineSeamError>

Terminates a linked in-VM activity process through AE’s process-link boundary. Read more
Source§

fn arm_timer(&self, entry: TimerWheelEntry) -> Result<(), EngineSeamError>

Arms a timer-wheel entry for a resident workflow process. Read more
Source§

fn disarm_timer( &self, process: WorkflowProcessHandle, timer_id: &TimerId, ) -> Result<(), EngineSeamError>

Disarms a timer-wheel entry for a resident workflow process. Read more
Source§

fn record_workflow_event( &self, workflow_id: &WorkflowId, event: Event, ) -> Result<(), EngineSeamError>

Records an event through the target workflow’s single AD Recorder. Read more

Auto Trait Implementations§

§

impl !Freeze for Engine

§

impl !RefUnwindSafe for Engine

§

impl !UnwindSafe for Engine

§

impl Send for Engine

§

impl Sync for Engine

§

impl Unpin for Engine

§

impl UnsafeUnpin for Engine

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more