Add manual task acknowledgement#637
Open
vvanglro wants to merge 1 commit into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #637 +/- ##
==========================================
+ Coverage 80.02% 80.20% +0.18%
==========================================
Files 69 69
Lines 2548 2577 +29
==========================================
+ Hits 2039 2067 +28
- Misses 509 510 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Some broker backends support explicit message acknowledgement, but taskiq currently only lets workers choose a fixed automatic acknowledgement point: when received, when executed, or when saved.
For some tasks, acknowledgement needs to happen after an application-level durable action is completed, but before the whole task finishes. Examples include committing an external transaction, persisting an idempotency marker, or coordinating with another system where the task code knows the correct acknowledgement boundary better than the worker.
This change adds an explicit
manualacknowledgement mode so advanced users can acknowledge from inside the task throughContext.ack(), while preserving the existing automatic acknowledgement behavior for all other modes.Summary
manualacknowledgement typeContext.ack(),Context.is_ackable, andContext.is_ackedfor task-level manual acknowledgementCompatibility
Existing acknowledgement modes are unchanged. Manual acknowledgement only works for brokers that yield
AckableMessage; otherwiseContext.ack()raises a clear runtime error.Tests
env -u PYTHONPATH -u VIRTUAL_ENV .venv/bin/python -m pytest -qenv -u PYTHONPATH -u VIRTUAL_ENV .venv/bin/python -m ruff check .env -u PYTHONPATH -u VIRTUAL_ENV .venv/bin/python -m black --check .