Celery Worker / Consumer OTP GenServer (ported from celery.worker).
Consumes Celery task messages from Redis (or memory:// in tests) via Kombu,
decodes Protocol v1 and v2 task messages, schedules ETA/countdown tasks, enforces
concurrency limits, executes tasks through Celery.Tracer, stores results in
Celery.Backend.Redis, and optionally listens for Kombu.Pidbox control commands.
Starting a Worker
celery = Celery.new(
broker: "redis://localhost:6379/0",
backend: "redis://localhost:6379/0",
include: ["src.tasks"]
)
{:ok, worker} = Celery.Worker.start_link(app: celery, concurrency: 4)
Summary
Functions
Returns the list of currently executing task requests (inspect.active).
Returns a specification to start this module under a supervisor.
Returns the list of prefetched/reserved task requests (inspect.reserved).
Revokes one or more task IDs on this worker.
Returns the list of revoked task IDs on this worker (inspect.revoked).
Returns the list of ETA-scheduled task requests (inspect.scheduled).
Starts a Celery.Worker linked to the calling process.
Returns worker statistics (inspect.stats).
Stops a running Celery.Worker gracefully.
Types
@type t() :: pid()
Functions
@spec active(GenServer.server()) :: [map()]
Returns the list of currently executing task requests (inspect.active).
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec reserved(GenServer.server()) :: [map()]
Returns the list of prefetched/reserved task requests (inspect.reserved).
@spec revoke(GenServer.server(), String.t() | [String.t()], keyword()) :: :ok
Revokes one or more task IDs on this worker.
@spec revoked(GenServer.server()) :: [String.t()]
Returns the list of revoked task IDs on this worker (inspect.revoked).
@spec scheduled(GenServer.server()) :: [map()]
Returns the list of ETA-scheduled task requests (inspect.scheduled).
@spec start_link(keyword()) :: GenServer.on_start()
Starts a Celery.Worker linked to the calling process.
Options
:app-%Celery{}instance (required, or built from remaining options):queues- list of queue names or%Kombu.Queue{}structs to consume from:hostname- worker node hostname (default"celery@<host>"):concurrency- maximum number of concurrent task processes (defaultapp.config.worker_concurrency):poll_interval- poll interval in milliseconds (default25):enable_remote_control- whether to start aKombu.Pidbox.Nodelistener (defaultfalse):notify- optional PID to receive{:celery_task_done, task_id, outcome}events:name- optional GenServer registration name
@spec stats(GenServer.server()) :: map()
Returns worker statistics (inspect.stats).
@spec stop(GenServer.server(), timeout()) :: :ok
Stops a running Celery.Worker gracefully.