Celery.Registry (celery v0.1.0)

Copy Markdown View Source

Task registry for Celery applications (ported from celery.app.registry.TaskRegistry).

Maintains a global ETS table mapping task names to %Celery.Task.Definition{} structs, while also supporting per-app task maps on %Celery{}.

Summary

Functions

Returns all registered tasks as a map of %{name => task_def}, merging global and app-specific tasks.

Returns a specification to start this module under a supervisor.

Fetches a task definition by name or raises Celery.NotRegistered.

Returns a sorted list of all registered task names.

Resolves a module from either an Elixir module atom (Src.Tasks) or a Python-style dotted module string ("src.tasks" -> Src.Tasks), loads its __celery_tasks__/0 definitions if present, and registers them.

Looks up a task definition by name in an optional app's local registry or the global registry.

Converts a Python-style dotted module name (e.g. "src.tasks") or Elixir module string (e.g. "Src.Tasks", "Elixir.Src.Tasks") into candidate Elixir module atoms.

Converts an Elixir module atom into a Python-style dotted module string (e.g. Src.Tasks -> "src.tasks").

Registers a %Celery.Task.Definition{} in the global registry.

Starts the global Celery task registry.

Unregisters a task by name from the global registry.

Functions

all(app \\ nil)

@spec all(map() | nil) :: %{required(String.t()) => map()}

Returns all registered tasks as a map of %{name => task_def}, merging global and app-specific tasks.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

fetch!(name, app \\ nil)

@spec fetch!(String.t(), map() | nil) :: map()

Fetches a task definition by name or raises Celery.NotRegistered.

keys(app \\ nil)

@spec keys(map() | nil) :: [String.t()]

Returns a sorted list of all registered task names.

load_include(mod)

@spec load_include(module() | String.t()) :: [map()]

Resolves a module from either an Elixir module atom (Src.Tasks) or a Python-style dotted module string ("src.tasks" -> Src.Tasks), loads its __celery_tasks__/0 definitions if present, and registers them.

lookup(name, app \\ nil)

@spec lookup(String.t(), map() | nil) ::
  {:ok, map()} | {:error, Celery.NotRegistered.t()}

Looks up a task definition by name in an optional app's local registry or the global registry.

module_candidates(mod_str)

@spec module_candidates(String.t()) :: [module()]

Converts a Python-style dotted module name (e.g. "src.tasks") or Elixir module string (e.g. "Src.Tasks", "Elixir.Src.Tasks") into candidate Elixir module atoms.

python_module_name(mod)

@spec python_module_name(module()) :: String.t()

Converts an Elixir module atom into a Python-style dotted module string (e.g. Src.Tasks -> "src.tasks").

register(task_def)

@spec register(map()) :: :ok

Registers a %Celery.Task.Definition{} in the global registry.

start_link(opts \\ [])

Starts the global Celery task registry.

unregister(name)

@spec unregister(String.t()) :: :ok

Unregisters a task by name from the global registry.