Entities
Pydantic models for the SQS event, the Celery task and the response returned by the handler.
SQS event and messages
- class celery_cloud.entities.sqs_entities.DeliveryInfo(*, exchange: str, routing_key: str)[source]
Bases:
BaseModelDelivery information for the SQS message.
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class celery_cloud.entities.sqs_entities.Headers(*, lang: str, task: str, id: str, shadow: str | None = None, eta: str | None = None, expires: str | None = None, group: str | None = None, group_index: int | None = None, compression: str | None = None, retries: int = 0, timelimit: list[float | None] = <factory>, root_id: str | None = None, parent_id: str | None = None, argsrepr: str | None = None, kwargsrepr: str | None = None, origin: str | None = None, ignore_result: bool = False, replaced_task_nesting: int = 0, stamped_headers: Any | None = None, stamps: dict[str, ~typing.Any]=<factory>)[source]
Bases:
BaseModelMetadata headers for the Celery task.
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class celery_cloud.entities.sqs_entities.Properties(*, correlation_id: str | None = None, reply_to: str | None = None, delivery_mode: int | None = None, delivery_info: DeliveryInfo | None = None, priority: int | None = None, body_encoding: str = 'base64', delivery_tag: str | None = None)[source]
Bases:
BaseModelProperties of the SQS message.
- delivery_info: DeliveryInfo | None
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class celery_cloud.entities.sqs_entities.SQSAttributes(*, ApproximateReceiveCount: str, SentTimestamp: str, ApproximateFirstReceiveTimestamp: str)[source]
Bases:
BaseModelMetadata attributes of the SQS message.
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class celery_cloud.entities.sqs_entities.SQSEvent(*, Records: list[SQSRecord])[source]
Bases:
BaseModelRepresentation of an AWS SQS event.
- Parameters:
BaseModel (_type_) – Pydantic base model.
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class celery_cloud.entities.sqs_entities.SQSMessage(*, body: str, content_encoding: str, content_type: str, headers: Headers, properties: Properties)[source]
Bases:
BaseModelModel representing an SQS message containing a Celery task.
- decode_body() Any[source]
Decodes the message body into a Python object.
For Celery protocol 2 with the JSON serializer this is
[args, kwargs, embed].
- classmethod from_record(record: SQSRecord) SQSMessage[source]
Build the message carried by an SQS record.
- Raises:
MessageDecodeException – If the record body is not a valid Celery message envelope.
- get_task() Task[source]
Get the Celery Task carried by this message.
The arguments are read from the message body, never from the
argsrepr/kwargsreprheaders: those are truncated, log-oriented representations that cannot be trusted to rebuild the arguments.- Raises:
TaskDecodeException – If the body or headers are not a valid task.
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- properties: Properties
- class celery_cloud.entities.sqs_entities.SQSRecord(*, messageId: str, receiptHandle: str, body: str, attributes: SQSAttributes, eventSource: str, eventSourceARN: str)[source]
Bases:
BaseModelModel representing a single SQS message.
- attributes: SQSAttributes
- get_message() dict[str, Any][source]
Decodes the base64-encoded body into a JSON dictionary.
- Raises:
MessageDecodeException – If the body is not base64 encoded JSON object.
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Task and route
- class celery_cloud.entities.task.Task(*, task: Annotated[str, MaxLen(max_length=150)], id: Annotated[str, MaxLen(max_length=150)], args: list[Any], kwargs: dict[str, Any], retries: int | None = 0, eta: str | None = None, expires: str | None = None, ignore_result: bool = False, queue: str | None = None, parent_id: str | None = None, root_id: str | None = None, group: str | None = None, group_index: int | None = None, callbacks: list[dict[str, Any]] | None = None, errbacks: list[dict[str, Any]] | None = None, chain: list[dict[str, Any]] | None = None, chord: dict[str, Any] | None = None, time_limit: float | None = None, soft_time_limit: float | None = None)[source]
Bases:
BaseModelRepresentation of a celery SQS task
- Parameters:
BaseModel (_type_) – _description_
- eta_seconds(now: datetime | None = None) float | None[source]
Seconds until
eta(None when there is none or it is not valid).
- is_expired(now: datetime | None = None) bool[source]
True when the task has an
expirestime that already passed.An unparseable value is treated as “does not expire” rather than discarding a task over a malformed header.
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class celery_cloud.entities.task_route.TaskRoute(scheme: str, module: str, function: str, query: dict[str, list[str]])[source]
Bases:
NamedTupleTask decoded route
- Parameters:
NamedTuple (_type_) – _description_
- class celery_cloud.entities.task_result.TaskResult(*, status: str, result: Any | None = None, traceback: str | None = None, children: list[Any] = <factory>, date_done: str | None = None, name: str | None = None, args: list[Any] | None = None, kwargs: dict[str, ~typing.Any] | None=None, worker: str | None = None, retries: int | None = None, queue: str | None = None, task_id: str)[source]
Bases:
BaseModelModel for the result of a task
- Parameters:
BaseModel (_type_) – _description_
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Handler response
- class celery_cloud.entities.lambda_response.BatchItemFailure(*, itemIdentifier: str)[source]
Bases:
BaseModelSQS partial batch response item: the message SQS must deliver again
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class celery_cloud.entities.lambda_response.DelayedTask(*, message_id: str, task_id: Annotated[str, MaxLen(max_length=150)], delay_seconds: int)[source]
Bases:
BaseModelA task held back until its
eta: its message was sent again, delayed- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class celery_cloud.entities.lambda_response.FailedTask(*, task_id: Annotated[str | None, MaxLen(max_length=150)] = None, message_id: str, error: str)[source]
Bases:
BaseModelRepresentation of a failed Celery task
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class celery_cloud.entities.lambda_response.LambdaResponse(*, status: str, processed_messages: int | None = None, failed_messages: int | None = None, skipped_messages: int | None = None, delayed_messages: int | None = None, delayed_tasks: list[DelayedTask] | None = None, skipped_tasks: list[SkippedTask] | None = None, processed_tasks: list[ProcessedTask] | None = None, failed_tasks: list[FailedTask] | None = None, batchItemFailures: list[BatchItemFailure] = <factory>, message: str | None = None, details: str | None = None)[source]
Bases:
BaseModelUnified response model for AWS Lambda processing Celery tasks
- batchItemFailures: list[BatchItemFailure]
- delayed_tasks: list[DelayedTask] | None
- failed_tasks: list[FailedTask] | None
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- processed_tasks: list[ProcessedTask] | None
- skipped_tasks: list[SkippedTask] | None
- class celery_cloud.entities.lambda_response.ProcessedTask(*, task_id: Annotated[str, MaxLen(max_length=150)], status: str, result: Any | None = None)[source]
Bases:
BaseModelRepresentation of a successfully processed Celery task
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class celery_cloud.entities.lambda_response.SkippedTask(*, message_id: str, task_id: Annotated[str, MaxLen(max_length=150)], reason: str)[source]
Bases:
BaseModelA message that was deliberately not executed (duplicate, expired…)
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].