Celery.Worker.Control (celery v0.1.0)

Copy Markdown View Source

Remote control and inspection commands for Celery workers over Kombu.Pidbox (ported from celery.worker.control and celery.app.control).

Supports standard Celery control/inspect methods:

  • ping -> %{"ok" => "pong"}
  • registered -> list of registered task names
  • active -> list of currently executing task request info maps
  • reserved -> list of prefetched/reserved task request info maps
  • scheduled -> list of ETA-scheduled task maps
  • revoked -> list of revoked task IDs
  • stats -> worker statistics dictionary
  • revoke -> revokes one or more task_ids

Summary

Functions

Broadcasts a control/inspect command to workers via Kombu.Pidbox.

Builds the handler map used by a Celery.Worker's Kombu.Pidbox.Node to respond to remote control and inspect requests from Python or Elixir Celery clients.

Creates a %Kombu.Pidbox.Mailbox{} for the given %Celery{} or %Celery.Config{}.

Pings active workers via Kombu.Pidbox and collects replies.

Broadcasts a revoke command for task_id (or a list of task IDs) to workers.

Functions

broadcast(app_or_config, command, arguments \\ %{}, opts \\ [])

@spec broadcast(Celery.t() | Celery.Config.t(), String.t(), map(), keyword()) ::
  :ok | {:ok, list()} | {:error, term()}

Broadcasts a control/inspect command to workers via Kombu.Pidbox.

build_handlers(worker_pid, app)

@spec build_handlers(pid(), Celery.t()) :: %{
  required(String.t()) => (term(), map() -> term())
}

Builds the handler map used by a Celery.Worker's Kombu.Pidbox.Node to respond to remote control and inspect requests from Python or Elixir Celery clients.

mailbox(app_or_config)

@spec mailbox(Celery.t() | Celery.Config.t()) :: Kombu.Pidbox.Mailbox.t()

Creates a %Kombu.Pidbox.Mailbox{} for the given %Celery{} or %Celery.Config{}.

ping(app_or_config, opts \\ [])

@spec ping(Celery.t() | Celery.Config.t(), keyword()) ::
  {:ok, list()} | {:error, term()}

Pings active workers via Kombu.Pidbox and collects replies.

revoke(app_or_config, task_ids, opts \\ [])

@spec revoke(Celery.t() | Celery.Config.t(), String.t() | [String.t()], keyword()) ::
  :ok | {:ok, list()} | {:error, term()}

Broadcasts a revoke command for task_id (or a list of task IDs) to workers.