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
endReturn values from run/1
{:ok, result}— workflow completes successfully{:error, reason}— workflow fails{:continue_as_new, args}— workflow restarts with fresh history