Declares a workflow module and generates its call-side surface.
defmodule Booking do
use Temporalex.Workflow, queue: "bookings"
@impl true
def id(%Fresha.Booking{id: pk}), do: "booking-#{pk}"
def id(pk) when is_integer(pk), do: "booking-#{pk}"
@impl true
def run(booking_id) do
# ...
end
end
handle = Booking.start!(booking_id)
receipt = Booking.execute!(booking_id)
:ok = Booking.signal!(booking_id, "capture_completed", %{status: "ok"})use options
:queue— the task queue this workflow's work and workers meet on. Required to generate the call-side surface; a module without it still compiles and can be started through the low-levelTemporalex.Client.:name— the wire type; defaults to the module name. Set it when the type must outlive the module name.:client— the client the generated functions use; defaults to the app's default client (Temporalex.Client).
Callbacks
id/1 derives the workflow id — Temporal's idempotency key — from whatever
callers naturally hold. Required to use the generated surface; return
:generate to opt out of derived ids deliberately.
input/1 (optional) maps the value callers pass into the durable input
history records. Defaults to identity. run/1 receives that input after
the client codec's round-trip — see RFC 0002 §9.
Client-side only
The generated functions are live client calls and raise inside workflow
code: on replay they would be nondeterministic. From within a workflow,
use Temporalex.Workflow.API.execute_child_workflow/3 and
API.signal_child_workflow/4 instead.