A runtime instance of a workflow execution.
Tracks the current state of a workflow as it progresses through steps, including which steps are active (being executed), completed, and the accumulated context.
Fields
id- unique identifier supplied by the callerworkflow- the workflow module being executedworkflow_version- the version of the workflow definition (positive integer, default 1)current_step- the step module currently being processed (ornil)status- one of:pending,:running,:waiting,:completed,:failedcontext-Hephaestus.Core.Contextwith initial data and step resultsstep_configs- per-step config overrides keyed by step moduleactive_steps-MapSetof step modules currently being executedcompleted_steps-MapSetof step modules that have finishedruntime_metadata- dynamic metadata accumulated from step executionstelemetry_metadata- caller metadata merged into emitted telemetry eventstelemetry_start_time- monotonic start time used to compute telemetry durationsexecution_history- list ofHephaestus.Core.ExecutionEntryrecords
Summary
Types
The lifecycle status of a workflow instance.
A workflow instance struct tracking execution state, active/completed steps, and context.
Functions
Creates a new workflow instance for the given workflow module and explicit ID.
Types
@type status() :: :pending | :running | :waiting | :completed | :failed
The lifecycle status of a workflow instance.
@type t() :: %Hephaestus.Core.Instance{ active_steps: MapSet.t(module()), completed_steps: MapSet.t(module()), context: Hephaestus.Core.Context.t(), current_step: module() | nil, execution_history: list(), id: String.t(), runtime_metadata: map(), status: status(), step_configs: %{optional(module()) => map()}, telemetry_metadata: map(), telemetry_start_time: integer() | nil, workflow: module(), workflow_version: pos_integer() }
A workflow instance struct tracking execution state, active/completed steps, and context.
Functions
@spec new(module(), pos_integer(), map(), String.t()) :: t()
Creates a new workflow instance for the given workflow module and explicit ID.
Parameters
workflow- the workflow module to executeversion- the workflow version (positive integer)context- a map of initial data passed to the workflowid- explicit identifier for the workflow instance
Examples
iex> instance = Instance.new(MyApp.Workflows.OrderFlow, 1, %{order_id: 123}, "orderid::123")
iex> instance.status
:pending
iex> instance.context.initial
%{order_id: 123}
iex> instance.workflow_version
1