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 (UUID v4)workflow- 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.
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
Creates a new workflow instance for the given workflow module.
Generates a UUID v4 identifier and initializes the instance with a :pending
status and the provided initial context.
Constructor overloads:
new/1— defaults version to1and context to%{}new/2— accepts either(workflow, context)or(workflow, version)new/3— accepts(workflow, version, context)
Parameters
workflow- the workflow module to executeversion- the workflow version (positive integer)context- a map of initial data passed to the workflow (default:%{})
Examples
iex> instance = Instance.new(MyApp.Workflows.OrderFlow, 1, %{order_id: 123})
iex> instance.status
:pending
iex> instance.context.initial
%{order_id: 123}
iex> instance.workflow_version
1With default empty context:
iex> instance = Instance.new(MyApp.Workflows.OrderFlow, 1)
iex> instance.context.initial
%{}
@spec new(module(), pos_integer(), map()) :: t()