Behaviour for application-defined durable tasks.
Persisted task names and queue names are explicit strings; Elixir module names are never used as durable protocol names implicitly.
Example
defmodule MyApp.SendEmail do
use Absurd.Task,
name: "send-email",
queue: "io",
default_max_attempts: 3
@impl Absurd.Task
def run(params, _context), do: {:ok, params}
end
Summary
Types
Compile-time metadata attached to a task module.
The explicit success or failure returned by a task callback.
Callbacks
Runs one attempt of a durable task.
Functions
Declares an application module as an Absurd task.
Types
@type metadata() :: %{ name: String.t(), queue: String.t() | nil, default_max_attempts: pos_integer() | nil, default_cancellation: keyword() | nil }
Compile-time metadata attached to a task module.
@type result() :: {:ok, Absurd.JSON.value()} | {:error, term()}
The explicit success or failure returned by a task callback.
Callbacks
@callback run(params :: Absurd.JSON.value(), context :: Absurd.Context.t()) :: result()
Runs one attempt of a durable task.