Functions available to workflow code. All calls delegate to the executor
via Process.get(:__temporal_executor__).
Sequential primitives (available anywhere)
execute_activity/3— schedule an activity, block until resultsleep/1— durable timerwait_for_signal/1— block until a named signal arrivesside_effect/1— run once, replay from historypublish_state/1— set query-visible statepatched?/1/deprecate_patch/1— workflow versioningcancelled?/0— check cancellation flag
Structured concurrency hosts
receive/2— message loop with signal/update handlersparallel/1— concurrent fan-out
Async-only (inside {:async, fn, state} handlers)
update_state/1— atomic read-modify-write of receive state
Summary
Functions
Check if the workflow has been cancelled.
Mark a patch as deprecated after all pre-patch executions complete.
Execute an activity. Blocks until the activity completes or fails.
Execute a local activity. Blocks until completion.
Execute functions concurrently. Blocks until all complete. Returns results in the same order as input functions.
Workflow versioning. Returns true on new executions, replays from history.
Publish a state snapshot visible to query handlers. Replaces previous state.
Enter a message-processing loop. Blocks the caller.
Execute fun once and return its value.
Durable timer. Blocks for duration_ms milliseconds.
Start a child workflow. Blocks until the child completes or fails.
Atomically read-modify-write the enclosing receive block's state. Only available inside async handler processes.
Block until a signal with name arrives. Consumes one from the buffer.
Functions
Check if the workflow has been cancelled.
Mark a patch as deprecated after all pre-patch executions complete.
Execute an activity. Blocks until the activity completes or fails.
Execute a local activity. Blocks until completion.
Local activities are short, in-process operations that the worker
runs directly without round-tripping through the Temporal task queue.
Use them for cheap deterministic-with-side-effects work (id
generation, current time, small lookups). Their result is recorded
in workflow history, so they survive worker crashes — unlike
side_effect/1 — making them the safe replacement for non-durable
inline functions.
Options:
:start_to_close_timeout_ms(default 30_000)
Execute functions concurrently. Blocks until all complete. Returns results in the same order as input functions.
Workflow versioning. Returns true on new executions, replays from history.
Publish a state snapshot visible to query handlers. Replaces previous state.
Enter a message-processing loop. Blocks the caller.
Options
:signal— map of signal name to handler function:update— map of update name to handler (or{handler, validator: fn}):timeout— milliseconds before auto-exit with{:timeout, state}
Handler return values
Signal handlers: {:noreply, state}, {:stop, state}, {:async, fn, state}
Update handlers: {:reply, response, state}, {:stop, response, state}, {:async, fn, state}
The state in {:async, fn, state} is ignored; use update_state/1 inside
the async fn to mutate the receive state safely alongside other async work.
Execute fun once and return its value.
Deprecated for non-deterministic work. Use execute_local_activity/3
(or defactivity ..., local: true) instead — local activities are
recorded in workflow history and survive worker crashes/cache evictions.
side_effect/1 is not durable across cache evictions: if the
workflow is evicted and later re-activated on a different worker,
fun runs again with a new value. Safe only for values whose
re-computation is acceptable (e.g. monitoring or logging
instrumentation).
Durable timer. Blocks for duration_ms milliseconds.
Start a child workflow. Blocks until the child completes or fails.
Options: :workflow_id, :task_queue, :cancellation_type, :parent_close_policy.
Atomically read-modify-write the enclosing receive block's state. Only available inside async handler processes.
The function receives current state and returns {return_value, new_state}.
Block until a signal with name arrives. Consumes one from the buffer.