Execution Backends#
Registry#
Execution backends are registered through litestar_queues.execution.
- litestar_queues.execution.get_execution_backend(backend: ExecutionBackendConfig = 'immediate', config: QueueConfig | None = None) BaseExecutionBackend[source]#
Get an instantiated execution backend.
- Returns:
A configured execution backend instance.
- Raises:
TypeError – If a typed execution config selects a backend class that does not accept
execution_config.
- litestar_queues.execution.get_execution_backend_class(backend_path: str) type[BaseExecutionBackend][source]#
Get an execution backend class by short name or import path.
- Returns:
The resolved execution backend class.
- Raises:
ValueError – If a short backend name is unknown.
- litestar_queues.execution.execution_backend(name: str) Callable[[type[BaseExecutionBackend]], type[BaseExecutionBackend]][source]#
Decorator to register an execution backend class with a short name.
- Returns:
A decorator that registers the backend class.
Base Backend#
- class litestar_queues.execution.base.BaseConsumerExecutionBackend(config: QueueConfig | None = None)[source]#
Bases:
BaseExecutionBackendBase for external backends that continuously receive broker deliveries.
- class litestar_queues.execution.base.BaseExecutionBackend(config: QueueConfig | None = None)[source]#
Bases:
objectBase class for queue execution backends.
- __init__(config: QueueConfig | None = None) None[source]#
Initialize the execution backend.
- config#
- property schedules_on_enqueue: bool#
Whether the backend schedules a persisted record without a Worker.
Deliberately separate from
is_external. Cloud Run Jobs and the broker backends are external but still rely on a worker loop noticing a pending record; only a managed transport that accepts the record itself answers true here.
- property max_schedule_horizon: timedelta | None#
How far ahead this backend will hold a scheduled delivery.
Nonemeans unbounded, which is every backend that keeps due records in the queue store. A managed transport that takes ownership of the record has its own ceiling, and a schedule past it is not a call that fails once – it is a recurrence that can never run.
- async schedule(service: QueueService, record: QueuedTaskRecord) str | None[source]#
Schedule one already-persisted record for external delivery.
- Returns:
The external delivery reference, if one was created.
- async repair(service: QueueService, *, limit: int) DispatchRepairResult[source]#
Recreate deliveries this backend owns that its transport no longer holds.
A no-op for every backend whose records are found by polling: nothing can go missing from a store the worker reads directly. Only a managed transport that took ownership of the record can lose it silently.
- Parameters:
service – The queue service whose records to repair.
limit – Ceiling on how many records one pass may examine. Bounded maintenance is the only caller, and it always passes a positive budget it needs back.
- Returns:
An empty result.
- async execute(service: QueueService, record: QueuedTaskRecord, *, worker_id: str | None = None) QueuedTaskRecord[source]#
Execute a queue record.
- async dispatch(service: QueueService, record: QueuedTaskRecord) str | None[source]#
Dispatch a queue record to an external executor.
- Returns:
The external execution reference, if one was created.
- async reconcile(service: QueueService, record: QueuedTaskRecord) QueuedTaskRecord | None[source]#
Reconcile an externally running queue record.
- Returns:
The updated record when reconciliation changes state.
- async cancel_execution(service: QueueService, record: QueuedTaskRecord) ExecutionCancelResult[source]#
Cancel the provider resource backing one external attempt.
Called before any durable transition to
cancelledfor a record whoseexecution_refnames a live provider resource. Implementations must contain their client’s exceptions and answer with a result: a not-found resource isalready_cancelled, anything transient or refused isretryable. Raising is reserved for programming errors.- Returns:
unsupportedfor a transport with no cancellation control plane.
- class litestar_queues.execution.base.DispatchRepairResult(examined: int = 0, changed: int = 0)[source]#
Bases:
objectOutcome of one bounded delivery-repair pass.
examinedis how much of the caller’s budget the pass consumed, whether or not a candidate needed anything done, so the caller can spend what is left on its other work.
- class litestar_queues.execution.base.ExecutionCancelResult(status: Literal['accepted', 'already_cancelled', 'retryable', 'unsupported'], detail: str | None = None)[source]#
Bases:
objectOutcome of one provider-level cancellation attempt.
detailcarries the provider’s own words for the log line and the lifecycle event; it is never parsed.- property permits_durable_cancel: bool#
Whether this outcome may win the durable transition to cancelled.
Only a control plane that exists and refused blocks the write. A transport with no control plane cannot strand anything, because the dispatch-by-id claim fence makes an in-flight delivery a no-op.
- Returns:
True unless the provider refused a cancellation it could have made.
- classmethod accepted(detail: str | None = None) Self[source]#
Return an accepted cancellation result.
- Returns:
A result whose status is
accepted.
- classmethod already_cancelled(detail: str | None = None) Self[source]#
Return an idempotent already-cancelled result.
- Returns:
A result whose status is
already_cancelled.
- classmethod retryable(detail: str | None = None) Self[source]#
Return a transient or rejected cancellation result.
- Returns:
A result whose status is
retryable.
Immediate#
- class litestar_queues.execution.immediate.ImmediateExecutionBackend(config: QueueConfig | None = None)[source]#
Bases:
BaseExecutionBackendExecution backend that runs records inline.
- async execute(service: QueueService, record: QueuedTaskRecord, *, worker_id: str | None = None) QueuedTaskRecord[source]#
Execute a task immediately in the current event loop.
- Returns:
The updated queue record.
Local#
- class litestar_queues.execution.local.LocalExecutionBackend(config: QueueConfig | None = None)[source]#
Bases:
BaseExecutionBackendExecution backend for in-process workers.
- async execute(service: QueueService, record: QueuedTaskRecord, *, worker_id: str | None = None) QueuedTaskRecord[source]#
Execute one claimed task in a local worker.
- Returns:
The updated queue record.
Cloud Run#
- class litestar_queues.execution.cloudrun.config.CloudRunExecutionConfig(project_id: str, region: str = 'us-central1', job_name: str | None = None, profiles: dict[str, str] = <factory>, timeout: int = 300, env_prefix: str | None = None, extra_env: dict[str, str] = <factory>, fallback_execution_backend: str | None = None)[source]#
Bases:
objectConfiguration for Cloud Run Jobs execution.
- __init__(project_id: str, region: str = 'us-central1', job_name: str | None = None, profiles: dict[str, str] = <factory>, timeout: int = 300, env_prefix: str | None = None, extra_env: dict[str, str] = <factory>, fallback_execution_backend: str | None = None) None#
- fallback_execution_backend: str | None#
Backend used after dispatch failure;
Nonepropagates the failure.
- class litestar_queues.execution.cloudrun.backend.CloudRunExecutionBackend(config: QueueConfig | None = None, *, execution_config: CloudRunExecutionConfig | None = None, jobs_client: CloudRunJobsClient | None = None, executions_client: CloudRunExecutionsClient | None = None)[source]#
Bases:
BaseExecutionBackendExecution backend that dispatches queued records to Cloud Run Jobs.
- __init__(config: QueueConfig | None = None, *, execution_config: CloudRunExecutionConfig | None = None, jobs_client: CloudRunJobsClient | None = None, executions_client: CloudRunExecutionsClient | None = None) None[source]#
Initialize the execution backend.
- jobs_client#
- executions_client#
- property execution_config: CloudRunExecutionConfig#
Resolved Cloud Run execution config.
- async execute(service: QueueService, record: QueuedTaskRecord, *, worker_id: str | None = None) QueuedTaskRecord[source]#
Dispatch a record and return its persisted state.
The
worker_idargument is accepted for protocol parity but not forwarded: external dispatch does not runservice.execute_recordlocally, so the remote runner is responsible for its own worker identity binding.- Returns:
The persisted queue record after dispatch.
- async dispatch(service: QueueService, record: QueuedTaskRecord) str | None[source]#
Dispatch a queue record to Cloud Run Jobs.
- Returns:
The Cloud Run execution reference, if dispatch succeeds.
- async cancel_execution(service: QueueService, record: QueuedTaskRecord) ExecutionCancelResult[source]#
Cancel the Cloud Run execution backing this record’s attempt.
- Returns:
The provider’s answer, mapped to the shared cancellation contract.
- async reconcile(service: QueueService, record: QueuedTaskRecord) QueuedTaskRecord | None[source]#
Reconcile a Cloud Run execution with the queue record.
- Returns:
The terminal queue record when reconciliation completed it.
- async check_execution_status(execution_ref: str) CloudRunExecutionStatus[source]#
Return Cloud Run execution status.
Transient API failures are treated as still running so reconciliation does not create false terminal queue states.
- build_run_job_request(service: QueueService, record: QueuedTaskRecord) dict[str, Any][source]#
Build the Cloud Run Jobs API request for a queue record.
- Returns:
Cloud Run Jobs API request data.
- build_task_env(record: QueuedTaskRecord) dict[str, str][source]#
Build the single-value task environment for a Cloud Run task process.
The record travels as its id in one prefix-aware environment variable (
QUEUES_TASK_ID); the consumer re-fetches the live record by that id. Adopterextra_envvalues are merged in.- Returns:
Environment variables for the Cloud Run task process.
Cloud Tasks#
- litestar_queues.execution.cloudtasks.config.CLOUD_TASKS_BACKEND_NAME = 'cloudtasks'#
Registry name of this execution backend, and its value on every metric label.
- litestar_queues.execution.cloudtasks.config.CLOUD_TASKS_MAX_SCHEDULE_HORIZON = datetime.timedelta(days=30)#
Google’s fixed ceiling on how far ahead a Cloud Tasks task may be scheduled.
- litestar_queues.execution.cloudtasks.config.CLOUD_TASKS_PROTOCOL_VERSION = 1#
Version stamped on every delivery body and required by the consumer route.
Lives here rather than beside either side of the wire so the producer and the route cannot drift apart while both still look correct on their own.
- class litestar_queues.execution.cloudtasks.config.CloudTasksExecutionConfig(project_id: str, location: str, queue_id: str, service_url: str, service_account_email: str, audience: str | None = None, route_path: str = <object object>, delivery_name_prefix: str | None = None, dispatch_deadline: int = 1800, response_margin: float = 30.0, default_task_timeout: float = 1740.0, api_timeout: float = 10.0, trust_platform_auth: bool = False, guards: tuple[Guard, ...] = ())[source]#
Bases:
objectConfiguration for Google Cloud Tasks managed dispatch.
Cloud Tasks delivers each persisted record over HTTP to a private consumer service, so this carries both the queue coordinates and the delivery target.
- audience: str | None#
OIDC audience;
Noneresolves to theservice_urlorigin.
- delivery_name_prefix: str | None#
Cloud Tasks task-name prefix;
Nonederives it fromQueueConfig.namespace.
- __init__(project_id: str, location: str, queue_id: str, service_url: str, service_account_email: str, audience: str | None = None, route_path: str = <object object>, delivery_name_prefix: str | None = None, dispatch_deadline: int = 1800, response_margin: float = 30.0, default_task_timeout: float = 1740.0, api_timeout: float = 10.0, trust_platform_auth: bool = False, guards: tuple[Guard, ...] = ()) None#
- resolve(namespace: QueueNamespace | None = None) CloudTasksExecutionConfig[source]#
Resolve namespace-owned defaults without mutating this reusable config.
Cloud Tasks execution backend.
Constructing the backend never builds a Google client: the client is resolved on
first use so an installation without the cloud-tasks extra can still import,
configure, and validate this backend.
Scheduling only ever runs against an already-durable record, and the delivery’s resource name is persisted before the create call so an ambiguous response still leaves a handle to look the delivery up by.
- class litestar_queues.execution.cloudtasks.backend.CloudTasksExecutionBackend(config: QueueConfig | None = None, *, execution_config: CloudTasksExecutionConfig | None = None, client: CloudTasksClient | None = None)[source]#
Bases:
BaseExecutionBackendExecution backend that hands persisted records to Google Cloud Tasks.
- __init__(config: QueueConfig | None = None, *, execution_config: CloudTasksExecutionConfig | None = None, client: CloudTasksClient | None = None) None[source]#
Initialize the Cloud Tasks execution backend.
- client#
- property schedules_on_enqueue: bool#
Whether the backend schedules a persisted record without a Worker.
- property execution_config: CloudTasksExecutionConfig#
Resolved Cloud Tasks execution config.
- async schedule(service: QueueService, record: QueuedTaskRecord) str | None[source]#
Create the Cloud Tasks delivery for an already-persisted record.
The record is read back rather than trusted: between the caller’s copy and this call it may have been cancelled, expired, or removed, and a delivery for an id storage no longer holds would retry against the consumer until it expired.
- Returns:
The delivery’s full resource name, or
Nonewhen the record is no longer eligible.- Raises:
Exception – Whatever prevented the delivery from being created, after the failure has been marked on the span. The record is committed, so the caller must not retry the enqueue.
- async repair(service: QueueService, *, limit: int) DispatchRepairResult[source]#
Recreate deliveries Cloud Tasks no longer holds for still-active records.
A delivery can go missing while its record stays active: a create call that failed after Google had already accepted it, an operator purging the queue, a retention window closing before the schedule time arrived. Nothing polls these records, so without this pass they wait forever.
Every candidate is attempted at most once per pass, so a queue whose target is broken cannot spin inside one maintenance window.
- Parameters:
service – The queue service whose records to repair.
limit – Ceiling on how many records this pass may examine.
- Returns:
How many records the pass looked at, and how many it re-delivered.
- async close() None[source]#
Release a client this backend created.
An injected client belongs to whoever built it and is left untouched.
- async cancel_execution(service: QueueService, record: QueuedTaskRecord) ExecutionCancelResult[source]#
Delete the Cloud Tasks delivery holding this record’s attempt.
Cloud Tasks holds a future delivery rather than a running process, so cancellation is a delete: after it, nothing will be delivered. A delivery that is already in flight has been claimed by the consumer, and the delete answers not-found – idempotent success, with the running body left to cooperative cancellation.
- Returns:
The provider’s answer, mapped to the shared cancellation contract.
The private HTTP route Cloud Tasks delivers each record to.
Cloud Tasks treats any non-2xx response as “deliver this again”. That is why this route answers so few statuses: every outcome the queue reached durably is acknowledged, whether the task succeeded, failed for the last time, was cancelled, or was already owned by someone else. None of those change if the same delivery arrives a second time.
Only two things earn a retryable answer – the queue could not be reached, and the retry this request just scheduled never made it to Google – because in both cases the redelivery is what repairs the record.
A request that cannot be authenticated or parsed is never acknowledged. That is a deployment fault, and letting Cloud Tasks retry it is what makes it visible.
- class litestar_queues.execution.cloudtasks.routes.CloudTasksDelivery(version: int, task_id: UUID)[source]#
Bases:
StructEverything that crosses the transport for one delivery.
Rejecting unknown fields is the point rather than strictness for its own sake: the record in storage is authoritative, so anything a caller adds here would either be ignored or, worse, believed.
- litestar_queues.execution.cloudtasks.routes.build_cloud_tasks_route(queue_config: QueueConfig) HTTPRouteHandler[source]#
Build the delivery route for a queue configured for Cloud Tasks.
- Returns:
The route handler Cloud Tasks posts each record to.
Amazon SQS#
- class litestar_queues.execution.sqs.config.SqsExecutionConfig(queue_url: str, region_name: str | None = None, endpoint_url: str | None = None, fifo: bool = False, message_group_id: str | None = None, wait_time_seconds: int = 20, receive_batch_size: int = 10, visibility_timeout: int = 60, visibility_extension_interval: int = 30, dispatch_stale_after: int = 60, api_timeout: float = 30)[source]#
Bases:
objectAmazon SQS execution-dispatch configuration.
- message_group_id: str | None#
Explicit FIFO group; when omitted a stable queue-name group is derived.
- __init__(queue_url: str, region_name: str | None = None, endpoint_url: str | None = None, fifo: bool = False, message_group_id: str | None = None, wait_time_seconds: int = 20, receive_batch_size: int = 10, visibility_timeout: int = 60, visibility_extension_interval: int = 30, dispatch_stale_after: int = 60, api_timeout: float = 30) None#
- class litestar_queues.execution.sqs.backend.SqsExecutionBackend(config: QueueConfig | None = None, *, execution_config: SqsExecutionConfig | None = None, client: Any | None = None)[source]#
Bases:
BaseConsumerExecutionBackendDispatch bare task identifiers through Amazon SQS.
- __init__(config: QueueConfig | None = None, *, execution_config: SqsExecutionConfig | None = None, client: Any | None = None) None[source]#
Initialize the execution backend.
- property execution_config: SqsExecutionConfig#
- async dispatch(service: QueueService, record: QueuedTaskRecord) str | None[source]#
Dispatch a queue record to an external executor.
- Returns:
The external execution reference, if one was created.
- async repair(service: QueueService, *, limit: int) DispatchRepairResult[source]#
Recreate deliveries this backend owns that its transport no longer holds.
A no-op for every backend whose records are found by polling: nothing can go missing from a store the worker reads directly. Only a managed transport that took ownership of the record can lose it silently.
- Parameters:
service – The queue service whose records to repair.
limit – Ceiling on how many records one pass may examine. Bounded maintenance is the only caller, and it always passes a positive budget it needs back.
- Returns:
An empty result.
- async execute(service: QueueService, record: QueuedTaskRecord, *, worker_id: str | None = None) QueuedTaskRecord[source]#
Execute a queue record.
RabbitMQ#
- class litestar_queues.execution.rabbitmq.config.RabbitMQExecutionConfig(amqp_url: str, queue_name: str | None = None, declare_queue: bool = True, dispatch_stale_after: int = 60, api_timeout: float = 30, delayed_retry_type: Literal['disabled', 'all', 'failed', 'returned'] = 'returned', delayed_retry_min_ms: int = 1000, delayed_retry_max_ms: int = 30000, consumer_timeout_ms: int | None = None)[source]#
Bases:
objectRabbitMQ execution-dispatch configuration.
- dispatch_stale_after: int#
Age in seconds after which an owned attempt can be rotated and republished.
- delayed_retry_type: Literal['disabled', 'all', 'failed', 'returned']#
RabbitMQ 4.3 quorum-queue delayed retry category.
- __init__(amqp_url: str, queue_name: str | None = None, declare_queue: bool = True, dispatch_stale_after: int = 60, api_timeout: float = 30, delayed_retry_type: Literal['disabled', 'all', 'failed', 'returned'] = 'returned', delayed_retry_min_ms: int = 1000, delayed_retry_max_ms: int = 30000, consumer_timeout_ms: int | None = None) None#
- class litestar_queues.execution.rabbitmq.backend.RabbitMQExecutionBackend(config: QueueConfig | None = None, *, execution_config: RabbitMQExecutionConfig | None = None, connection: Any | None = None)[source]#
Bases:
BaseConsumerExecutionBackendDispatch bare task identifiers through a RabbitMQ quorum queue.
- __init__(config: QueueConfig | None = None, *, execution_config: RabbitMQExecutionConfig | None = None, connection: Any | None = None) None[source]#
Initialize the execution backend.
- property execution_config: RabbitMQExecutionConfig#
- async dispatch(service: QueueService, record: QueuedTaskRecord) str | None[source]#
Dispatch a queue record to an external executor.
- Returns:
The external execution reference, if one was created.
- async repair(service: QueueService, *, limit: int) DispatchRepairResult[source]#
Recreate deliveries this backend owns that its transport no longer holds.
A no-op for every backend whose records are found by polling: nothing can go missing from a store the worker reads directly. Only a managed transport that took ownership of the record can lose it silently.
- Parameters:
service – The queue service whose records to repair.
limit – Ceiling on how many records one pass may examine. Bounded maintenance is the only caller, and it always passes a positive budget it needs back.
- Returns:
An empty result.
- async execute(service: QueueService, record: QueuedTaskRecord, *, worker_id: str | None = None) QueuedTaskRecord[source]#
Execute a queue record.
Kafka#
- class litestar_queues.execution.kafka.config.KafkaExecutionConfig(bootstrap_servers: str, topic: str = 'litestar-queues', consumer_group: str = 'litestar-queues', dispatch_stale_after: int = 60, api_timeout: float = 30, producer_options: dict[str, ~typing.Any] = <factory>, consumer_options: dict[str, ~typing.Any] = <factory>)[source]#
Bases:
objectKafka execution-dispatch configuration.
- __init__(bootstrap_servers: str, topic: str = 'litestar-queues', consumer_group: str = 'litestar-queues', dispatch_stale_after: int = 60, api_timeout: float = 30, producer_options: dict[str, ~typing.Any] = <factory>, consumer_options: dict[str, ~typing.Any] = <factory>) None#
- class litestar_queues.execution.kafka.backend.KafkaExecutionBackend(config: QueueConfig | None = None, *, execution_config: KafkaExecutionConfig | None = None, producer: KafkaProducer | None = None, consumer: KafkaConsumer | None = None)[source]#
Bases:
BaseConsumerExecutionBackendDispatch bare task identifiers through a Kafka consumer group.
- __init__(config: QueueConfig | None = None, *, execution_config: KafkaExecutionConfig | None = None, producer: KafkaProducer | None = None, consumer: KafkaConsumer | None = None) None[source]#
Initialize the execution backend.
- property execution_config: KafkaExecutionConfig#
- async dispatch(service: QueueService, record: QueuedTaskRecord) str | None[source]#
Dispatch a queue record to an external executor.
- Returns:
The external execution reference, if one was created.
- async repair(service: QueueService, *, limit: int) DispatchRepairResult[source]#
Recreate deliveries this backend owns that its transport no longer holds.
A no-op for every backend whose records are found by polling: nothing can go missing from a store the worker reads directly. Only a managed transport that took ownership of the record can lose it silently.
- Parameters:
service – The queue service whose records to repair.
limit – Ceiling on how many records one pass may examine. Bounded maintenance is the only caller, and it always passes a positive budget it needs back.
- Returns:
An empty result.
- async execute(service: QueueService, record: QueuedTaskRecord, *, worker_id: str | None = None) QueuedTaskRecord[source]#
Execute a queue record.
Google Cloud Pub/Sub#
- class litestar_queues.execution.pubsub.config.PubSubExecutionConfig(project_id: str, topic_id: str, subscription_id: str, ack_deadline: int = 60, ack_extension_interval: int = 30, dispatch_stale_after: int = 60, api_timeout: float = 30, api_endpoint: str | None = None, api_insecure: bool = False)[source]#
Bases:
objectGoogle Cloud Pub/Sub execution-dispatch configuration.
- class litestar_queues.execution.pubsub.backend.PubSubExecutionBackend(config: QueueConfig | None = None, *, execution_config: PubSubExecutionConfig | None = None, publisher: PubSubPublisherClient | None = None, subscriber: PubSubSubscriberClient | None = None)[source]#
Bases:
BaseConsumerExecutionBackendDispatch bare task identifiers through Google Cloud Pub/Sub.
- __init__(config: QueueConfig | None = None, *, execution_config: PubSubExecutionConfig | None = None, publisher: PubSubPublisherClient | None = None, subscriber: PubSubSubscriberClient | None = None) None[source]#
Initialize the execution backend.
- property execution_config: PubSubExecutionConfig#
Return the effective Pub/Sub configuration.
- async dispatch(service: QueueService, record: QueuedTaskRecord) str | None[source]#
Reserve and publish one task-id delivery.
- async repair(service: QueueService, *, limit: int) DispatchRepairResult[source]#
Rotate and republish stale attempt references.
- async execute(service: QueueService, record: QueuedTaskRecord, *, worker_id: str | None = None) QueuedTaskRecord[source]#
Dispatch a record and return its latest persisted state.
Consumer#
The programmatic entry point for an external executor: run one queued record by
id and exit with a deterministic code. This is the in-process twin of
litestar queues run-task – use it from a serverless handler or a custom
runner that cannot shell out. The live queue record stays authoritative; the
consumer re-fetches it by id and fences on the retry count at claim time.
Public, framework-agnostic consumer API for external execution backends.
run_task / consume_one / TaskExitCode are the programmatic twin of
litestar queues run-task: run one queued record by id on any external
executor (a Cloud Run Job, a serverless handler, a custom runner) and exit with
a deterministic code. Click-free on purpose so broker consumers and in-process
handlers can import them without pulling click into the module graph (see
test_plugin_lifecycle import boundary).
- class litestar_queues.consumer.TaskExitCode(value)[source]#
Bases:
IntEnumDeterministic external-consumer process exit codes.
CANCELLEDreports a record whose durable execution result iscancelled. A consumer whose own caller was cancelled reports nothing at all: the cancellation propagates instead, because the record is still running and no outcome has been reached.- SUCCESS = 0#
- FAILURE = 1#
- MISSING_TASK_ID = 2#
- INVALID_TASK_ID = 3#
- MISSING_RECORD = 4#
- UNKNOWN_TASK = 5#
- CLAIM_LOST = 6#
- CANCELLED = 7#
- MISSING_CONFIG_FACTORY = 8#
- async litestar_queues.consumer.consume_one(queue: QueueService, task_id: UUID, *, expected_retry_count: int | None = None, expected_execution_ref: str | None = None) TaskExitCode[source]#
Claim, execute, and report one queued record identified by its id.
The live record in the queue backend is authoritative; the id only locates it. Redelivery is fenced by the live
expected_retry_countat claim time.The claim is taken before the task name is resolved, because retiring a record this process cannot run is itself a write, and a persistent backend only accepts one over a record that is running and owned.
- Returns:
A deterministic task exit code.
- async litestar_queues.consumer.run_task(*, config: QueueConfig | None = None, service: QueueService | None = None, service_factory: ServiceFactory | None = None, task_id: str | None = None, config_factory: str | None = None, task_modules: str | None = None, env: Mapping[str, str] | None = None) TaskExitCode[source]#
Resolve a service and run one queued task by id.
The prefix-aware environment is the default source for every input; the override arguments take precedence over it.
config_factoryreplaces theCONFIG_FACTORYenv var,task_idreplaces theTASK_IDvalue, andtask_modulesreplacesTASK_MODULES.- Returns:
A deterministic task exit code.