Defines activities that workflows can call.
defmodule MyApp.Activities.Payment do
use Temporalex.Activity
defactivity charge(amount), timeout: 30_000 do
Stripe.charge(amount)
end
endEach defactivity generates two functions:
charge(amount)— dispatch function called from workflow code. Sends{:execute_activity, type, input, opts}to the executor.__charge__/1— implementation function called by the server when an activity task arrives. Public for direct use in tests.
The module also generates __temporal_activities__/0 returning
[{name, opts}] for registration.
Summary
Functions
Define an activity with a name, optional options, and a body.
Functions
Define an activity with a name, optional options, and a body.
Options:
:timeout— schedule-to-close timeout in ms (default: 30_000):heartbeat_timeout— heartbeat timeout in ms:retry_policy— retry configuration map:local— when true, the dispatch function callsexecute_local_activity/3instead. Use for short, in-process operations (id generation, current time, lookups). Local activities are recorded in workflow history and survive worker crashes.:start_to_close_timeout_ms— local activity timeout (default: 30_000)