Task lifecycle¶
Tasks move through four statuses:
new: available for leasingpending: leased by a workersuccessful: completed successfullyfailed: permanently failed or expired
Typical flow¶
append()inserts a task innew.next()leases a task, updates it topending, and setsassignedTo.- The worker calls
on_success()oron_failure(). on_success()updates status tosuccessful.on_failure()increments retries and either requeues or marksfailed.
Leasing and visibility¶
If visibility_timeout > 0, a lease expiration timestamp is stored as
leaseExpiresAt. Calling refresh() requeues expired leases by setting
status=new and clearing assignment fields.
TTL expiry¶
If ttl is set, tasks that remain pending longer than ttl are marked
failed during refresh().
Discarding¶
Tasks with retry count at or above max_retries are discarded during
refresh(). The action depends on discard_strategy:
- keep: keep tasks in place and mark them failed
- remove: delete tasks, optionally copying to the dead-letter collection