Runs hooks during the execute phase without requiring workflow access.
This module provides a safe, parallel-friendly way to execute hooks. Hooks can be either:
New-style (arity-2):
fn event, context -> :ok | {:apply, fn} | {:error, term} end- Executed during the execute phase
- Can return
:okor anapply_fnfor deferred workflow modifications
Legacy (arity-3):
fn step, workflow, fact -> workflow end- Converted to apply_fn for backward compatibility
- NOT executed during execute phase (requires workflow)
Return Types
Hooks can return:
:ok- Hook completed successfully, no workflow modifications{:apply, apply_fn}- Hook completed, apply_fn will be called during apply phase{:apply, [apply_fn]}- Multiple apply functions{:error, reason}- Hook failed, will cause runnable to fail
Summary
Functions
Runs after hooks with the execution result and collects any apply_fns.
Runs before hooks and collects any apply_fns.
Types
@type apply_fn() :: (Runic.Workflow.t() -> Runic.Workflow.t())
@type hook() :: new_hook() | legacy_hook()
@type legacy_hook() :: (struct(), Runic.Workflow.t(), Runic.Workflow.Fact.t() -> Runic.Workflow.t())
@type new_hook() :: (Runic.Workflow.HookEvent.t(), Runic.Workflow.CausalContext.t() -> hook_return())
Functions
@spec run_after( Runic.Workflow.CausalContext.t(), struct(), Runic.Workflow.Fact.t(), term() ) :: {:ok, [apply_fn()]} | {:error, term()}
Runs after hooks with the execution result and collects any apply_fns.
Returns {:ok, apply_fns} or {:error, reason}.
@spec run_before(Runic.Workflow.CausalContext.t(), struct(), Runic.Workflow.Fact.t()) :: {:ok, [apply_fn()]} | {:error, term()}
Runs before hooks and collects any apply_fns.
Returns {:ok, apply_fns} or {:error, reason}.