Raxol. Workflow. Node behaviour
(Raxol v2.6.0)
View Source
Node descriptors for Raxol.Workflow.Graph.
A node is one of three shapes:
FunctionNode-- a 1-arity function(state -> result)BehaviourNode-- a module implementing this module's behaviourTypedNode-- a struct with aRaxol.Workflow.Node.Executorprotocol implementation. Mirrors theRaxol.Core.Runtime.Directivepattern: lets external packages register typed nodes (e.g.%Raxol.ACP.Workflow.Node.CreateMemo{...}) with custom telemetry and validation.
Node functions return one of:
{:ok, state}-- proceed with the new state{:effects, [directive], state}-- emit directives and proceed{:interrupt, value}-- pause the run for human-in-the-loop resume{:error, reason}-- fail (handled by the workflow's failure policy)
FunctionNodes also accept an optional 1-arity compensation function
that runs in reverse order under failure_policy: :compensate.
Summary
Callbacks
Called by the runtime's failure policy when failure_policy: :compensate
is set and the run errors after this node already succeeded. Receives
the current state (potentially modified by later compensations) and
returns either an updated state via {:ok, new_state} or an error
via {:error, reason}. Compensation errors are surfaced through
node.compensated telemetry but do not displace the run's original
failure reason. Default is a no-op that leaves the state untouched.
Called once at run start to set up node-private state.
Called once per visit to the node. Returns the next state, an
interrupt, an error, or a state plus a list of Raxol.Core.Runtime.Directive
structs to dispatch through the runtime's existing effect pipeline.
Functions
Construct a BehaviourNode.
Construct a FunctionNode.
Construct a FunctionNode with an optional compensation function.
Return the node's id.
Construct a TypedNode.
Types
@type state() :: any()
@type t() :: Raxol.Workflow.Node.FunctionNode.t() | Raxol.Workflow.Node.BehaviourNode.t() | Raxol.Workflow.Node.TypedNode.t()
Callbacks
Called by the runtime's failure policy when failure_policy: :compensate
is set and the run errors after this node already succeeded. Receives
the current state (potentially modified by later compensations) and
returns either an updated state via {:ok, new_state} or an error
via {:error, reason}. Compensation errors are surfaced through
node.compensated telemetry but do not displace the run's original
failure reason. Default is a no-op that leaves the state untouched.
Called once at run start to set up node-private state.
Optional. Default returns the run's initial state unchanged.
Called once per visit to the node. Returns the next state, an
interrupt, an error, or a state plus a list of Raxol.Core.Runtime.Directive
structs to dispatch through the runtime's existing effect pipeline.
Functions
@spec behaviour(id(), module(), keyword()) :: Raxol.Workflow.Node.BehaviourNode.t()
Construct a BehaviourNode.
@spec function(id(), (state() -> result())) :: Raxol.Workflow.Node.FunctionNode.t()
Construct a FunctionNode.
@spec function(id(), (state() -> result()), (state() -> {:ok, state()} | {:error, any()})) :: Raxol.Workflow.Node.FunctionNode.t()
Construct a FunctionNode with an optional compensation function.
The compensation runs in reverse order under
failure_policy: :compensate when the run fails after this node
succeeded. It must be a 1-arity function returning
{:ok, new_state} | {:error, reason}.
Return the node's id.
@spec typed( id(), struct() ) :: Raxol.Workflow.Node.TypedNode.t()
Construct a TypedNode.