Celery.Worker.Request (celery v0.1.0)

Copy Markdown View Source

Worker task request wrapper (ported from celery.worker.request.Request).

Wraps a decoded %Celery.Task.Context{} and its underlying %Kombu.Message{} to manage message acknowledgement (acks_late), rejection, expiration, and inspection metadata.

Summary

Functions

Acknowledges the underlying %Kombu.Message{} if not already acknowledged.

Creates a %Celery.Worker.Request{} from a %Kombu.Message{} and worker hostname.

Returns an inspection dictionary matching Python Celery's Request.info().

Rejects the underlying %Kombu.Message{} (with requeue: boolean()).

Types

t()

@type t() :: %Celery.Worker.Request{
  acknowledged: boolean(),
  context: Celery.Task.Context.t(),
  hostname: String.t(),
  id: String.t(),
  message: Kombu.Message.t() | nil,
  name: String.t(),
  time_start: float() | nil,
  worker_pid: pid() | nil
}

Functions

acknowledge(req)

@spec acknowledge(t()) :: {t(), :ok | {:error, term()}}

Acknowledges the underlying %Kombu.Message{} if not already acknowledged.

from_message(message, hostname)

@spec from_message(Kombu.Message.t(), String.t()) :: {:ok, t()} | {:error, term()}

Creates a %Celery.Worker.Request{} from a %Kombu.Message{} and worker hostname.

info(req)

@spec info(t()) :: map()

Returns an inspection dictionary matching Python Celery's Request.info().

reject(req, opts)

@spec reject(t(), keyword()) :: {t(), :ok | {:error, term()}}

Rejects the underlying %Kombu.Message{} (with requeue: boolean()).