primus.command_worker.adapters.dynamodb_lifecycle module

DynamoDB implementation of the portable command lifecycle port.

The adapter owns only execution lifecycle state. Command submission and broker publication remain separate concerns because DynamoDB cannot atomically write an SQS message. Metadata is written by the command repository at:

pk=COMMAND#<command_id>, sk=META

with tenant and immutable envelope fields, a request digest, lifecycle status, numeric fencing token, lease fields, and expires_at_epoch TTL. Every execution mutation is conditionally fenced by that numeric token.

class primus.command_worker.adapters.dynamodb_lifecycle.DynamoDBLifecycleStore(table: Any)

Bases: object

LifecycleStore backed by one canonical DynamoDB metadata item per command.

__init__(table: Any) → None
claim(envelope: CommandEnvelope, owner: str, now: datetime, lease_duration: timedelta) → Claim | ClaimStatus
complete(command_id: str, token: str, result: str | int | float | bool | None | Mapping[str, JSONValue] | tuple[JSONValue, ...], now: datetime) → bool
fail(command_id: str, token: str, error: str, now: datetime) → bool
finalize_cancel(command_id: str, token: str, now: datetime) → bool
renew(command_id: str, token: str, now: datetime, lease_duration: timedelta) → Claim | None
report_progress(command_id: str, token: str, progress: ProgressUpdate, now: datetime) → bool