aion/runtime/workflow.rs
1//! Workflow process helpers exposed by `RuntimeHandle`.
2
3use aion_core::{Payload, WorkflowError};
4
5use crate::{EngineError, Pid, RuntimeHandle};
6
7impl RuntimeHandle {
8 /// Block until a workflow exits and convert its terminal runtime outcome.
9 ///
10 /// Normal returns become durable result payloads. Abnormal exits become typed
11 /// workflow errors so lifecycle code can record a terminal failure.
12 ///
13 /// # Errors
14 ///
15 /// Returns [`EngineError::Runtime`] when the result term cannot be converted
16 /// into a payload.
17 pub fn workflow_outcome(
18 &self,
19 pid: Pid,
20 ) -> Result<Result<Payload, WorkflowError>, EngineError> {
21 let owned = self.process_exits.get(pid)?.wait()?;
22 let outcome = super::outcome::workflow_outcome(&self.atom_table, pid, &owned);
23 self.release_spawn_heaps(pid);
24 outcome
25 }
26}