Raxol.Workflow.Compiled (Raxol v2.6.0)

View Source

Frozen, validated workflow ready for execution.

Returned by Raxol.Workflow.Graph.compile/2. The struct is opaque in the sense that consumers should not construct or pattern-match on its fields directly; the runtime API exposed here is the supported interface.

Runtime entry points

Summary

Functions

Spawn the run in a background process; return an immediate handle.

Spawn a resume in a background process; return an immediate handle.

Run the compiled graph synchronously.

Return a lazy Stream of Raxol.Core.Events.CloudEvent structs emitted by the resume invocation.

Types

opts()

@type opts() :: %{
  optional(:failure_policy) => :retry | :halt | :compensate,
  optional(:max_attempts) => pos_integer(),
  optional(:retry_backoff_ms) => non_neg_integer(),
  optional(:step_timeout_ms) => non_neg_integer(),
  optional(:run_timeout_ms) => non_neg_integer(),
  optional(:saver) => module()
}

t()

@type t() :: %Raxol.Workflow.Compiled{
  channels: %{required(atom() | binary()) => Raxol.Workflow.Channel.t()},
  edges_by_source: %{
    required(Raxol.Workflow.Node.id()) => [Raxol.Workflow.Edge.t()]
  },
  id: atom() | binary(),
  joins_by_node: %{
    required(Raxol.Workflow.Node.id()) => Raxol.Workflow.Edge.JoinEdge.t()
  },
  joins_by_upstream: %{
    required(Raxol.Workflow.Node.id()) => Raxol.Workflow.Edge.JoinEdge.t()
  },
  nodes: %{required(Raxol.Workflow.Node.id()) => Raxol.Workflow.Node.t()},
  opts: opts()
}

Functions

async_invoke(compiled, initial_state, opts \\ [])

@spec async_invoke(t(), any(), keyword()) ::
  {:ok, %{run_id: binary(), pid: pid(), ref: reference()}}

Spawn the run in a background process; return an immediate handle.

Delegates to Raxol.Workflow.Async.async_invoke/3. See that module for the returned handle shape and the supported opts.

async_resume(compiled, run_id, resume_value, opts \\ [])

@spec async_resume(t(), binary(), any(), keyword()) ::
  {:ok, %{run_id: binary(), pid: pid(), ref: reference()}}
  | {:error, :no_saver_configured | :no_checkpoint, nil}

Spawn a resume in a background process; return an immediate handle.

Delegates to Raxol.Workflow.Async.async_resume/4.

invoke(compiled, initial_state, opts \\ [])

@spec invoke(t(), any(), keyword()) :: Raxol.Workflow.Runtime.result()

Run the compiled graph synchronously.

Delegates to Raxol.Workflow.Runtime.invoke/3. See that module for the full result-tuple contract and the supported opts.

resume(compiled, run_id, resume_value, opts \\ [])

@spec resume(t(), binary(), any(), keyword()) ::
  Raxol.Workflow.Runtime.result()
  | {:error, :no_saver_configured | :no_checkpoint, nil}

Resume an interrupted run.

Delegates to Raxol.Workflow.Runtime.resume/4. See that module for the full result-tuple contract and error tuples.

resume_events(compiled, run_id, resume_value, opts \\ [])

@spec resume_events(t(), binary(), any(), keyword()) :: Enumerable.t()

Return a lazy Stream of Raxol.Core.Events.CloudEvent structs emitted by the resume invocation.

Delegates to Raxol.Workflow.Async.resume_events/4.

stream_events(compiled, initial_state, opts \\ [])

@spec stream_events(t(), any(), keyword()) :: Enumerable.t()

Return a lazy Stream of Raxol.Core.Events.CloudEvent structs emitted by the run.

Delegates to Raxol.Workflow.Async.stream_events/3.