Temporalex.Workflow (Temporalex v0.2.0)

Copy Markdown View Source

Defines a Temporal workflow.

A workflow is a module with a run/1 function that reads top-to-bottom as sequential code. Concurrency is introduced through API.receive and API.parallel.

defmodule MyApp.Workflows.Checkout do
  use Temporalex.Workflow

  def handle_query("status", _args, state), do: {:reply, state}

  def run(args) do
    {:ok, charge} = Activities.Payment.charge(args)
    {:ok, %{charge_id: charge.id}}
  end
end

Return values from run/1

  • {:ok, result} — workflow completes successfully
  • {:error, reason} — workflow fails
  • {:continue_as_new, args} — workflow restarts with fresh history