Validated task lookup for one worker-pool queue.
A catalog is built from an explicit list of Absurd.Task modules or from a
module implementing this module's tasks/0 callback. Construction loads
task metadata, requires a Absurd.Task.run/2 implementation, rejects queue
mismatches, and rejects duplicate durable names before a worker can claim
work.
Catalogs are immutable and local to their worker pool. There is no global module scan or runtime atom creation.
Examples
iex> {:ok, catalog} = Absurd.TaskCatalog.new([], "default")
iex> {catalog.queue, Absurd.TaskCatalog.size(catalog)}
{"default", 0}An application catalog keeps a larger worker configuration focused:
defmodule MyApp.AbsurdTasks do
@behaviour Absurd.TaskCatalog
@impl Absurd.TaskCatalog
def tasks, do: [MyApp.SendEmail, MyApp.GenerateInvoice]
end
Summary
Functions
Returns the module registered for a durable task name, or nil.
Builds and validates a catalog for queue.
Returns the number of registered task names.
Types
Callbacks
@callback tasks() :: [module()]
Returns the task modules supplied by an application catalog module.
Functions
Returns the module registered for a durable task name, or nil.
@spec new([module()] | module(), String.t()) :: {:ok, t()} | {:error, Absurd.Error.t()}
Builds and validates a catalog for queue.
source may be a list of task modules or a module implementing tasks/0.
Task metadata with no queue inherits queue; explicit metadata must match it.
@spec size(t()) :: non_neg_integer()
Returns the number of registered task names.