SquidMesh.Runtime.Dispatcher (squid_mesh v0.1.0-alpha.7)

Copy Markdown View Source

Enqueues durable workflow step execution.

The workflow contract stays declarative while this module bridges runtime intent into the host application's configured executor.

Summary

Types

dispatch_error()

@type dispatch_error() :: Ecto.Changeset.t() | term()

dispatch_event()

@type dispatch_event() :: {:run_dispatched, SquidMesh.Run.t(), dispatch_metadata()}

dispatch_metadata()

@type dispatch_metadata() :: SquidMesh.Executor.metadata()

dispatch_opts()

@type dispatch_opts() :: [{:schedule_in, pos_integer()}]

dispatch_target()

@type dispatch_target() :: atom()

Functions

dispatch_compensation_with_events(config, run)

@spec dispatch_compensation_with_events(SquidMesh.Config.t(), SquidMesh.Run.t()) ::
  {:ok, dispatch_metadata(), [dispatch_event()]} | {:error, dispatch_error()}

Enqueues the durable compensation worker for a failed run.

This is called from the same transaction that marks the run failed, giving the terminal run transition and compensation dispatch the same atomicity as normal successor-step dispatch.

dispatch_run(config, run, opts \\ [])

@spec dispatch_run(SquidMesh.Config.t(), SquidMesh.Run.t(), dispatch_opts()) ::
  {:ok, dispatch_metadata() | [dispatch_metadata()]}
  | {:error, dispatch_error()}

dispatch_run_with_events(config, run, opts \\ [])

@spec dispatch_run_with_events(
  SquidMesh.Config.t(),
  SquidMesh.Run.t(),
  dispatch_opts()
) ::
  {:ok, dispatch_metadata() | [dispatch_metadata()], [dispatch_event()]}
  | {:error, dispatch_error()}

dispatch_steps(config, run, steps, opts \\ [])

@spec dispatch_steps(
  SquidMesh.Config.t(),
  SquidMesh.Run.t(),
  [dispatch_target()],
  keyword()
) ::
  {:ok, dispatch_metadata() | [dispatch_metadata()]}
  | {:error, dispatch_error()}

dispatch_steps_with_events(config, run, steps, opts \\ [])

@spec dispatch_steps_with_events(
  SquidMesh.Config.t(),
  SquidMesh.Run.t(),
  [dispatch_target()],
  keyword()
) ::
  {:ok, dispatch_metadata() | [dispatch_metadata()], [dispatch_event()]}
  | {:error, dispatch_error()}