feature: Adds queue backlog management and queue position visibility #69
Merged
JoeGaffney merged 5 commits intomainfrom Jan 22, 2026
Merged
feature: Adds queue backlog management and queue position visibility #69JoeGaffney merged 5 commits intomainfrom
JoeGaffney merged 5 commits intomainfrom
Conversation
…limit on api key rate limit on pending capacity
Contributor
There was a problem hiding this comment.
Pull request overview
Adds queue backlog management and queue position visibility across API task polling, plus introduces worker-level global task timeouts and extends text responses to include logs.
Changes:
- Add Redis-backed helpers to report pending-task queue position via
logsin GET endpoints (images/texts/videos/workflows). - Replace per-key rate limiting with a global backlog limit based on Redis queue lengths.
- Add global Celery hard/soft task timeouts and extend TextResponse schemas/OpenAPI to include
logs.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| workers/worker.py | Adds global Celery soft/hard time limits for tasks. |
| workers/texts/schemas.py | Adds logs field to text response schema for workers. |
| workers/common/schemas.py | Adds QueuePosition model to worker shared schemas. |
| clients/openapi.json | Regenerates OpenAPI to reflect new logs field in TextResponse. |
| api/workflows/router.py | Injects queue position logs for PENDING workflow tasks. |
| api/videos/router.py | Injects queue position logs for PENDING video tasks. |
| api/texts/schemas.py | Adds logs field to text response schema for API. |
| api/texts/router.py | Injects queue position logs for PENDING text tasks. |
| api/images/router.py | Injects queue position logs for PENDING image tasks. |
| api/common/task_helpers.py | Adds helper to format queue-position information into logs. |
| api/common/schemas.py | Adds QueuePosition model to API shared schemas. |
| api/common/redis_manager.py | Introduces Redis-backed queue length + queue position lookup (Lua). |
| api/common/config.py | Adds task_backlog_limit setting to cap waiting tasks. |
| api/common/auth.py | Enforces backlog limit on POST task creation (replaces per-key rate limit). |
| api/admin/router.py | Switches admin key management over to redis_manager. |
Comments suppressed due to low confidence (4)
api/common/redis_manager.py:137
- Avoid using a mutable default argument for
queues. If this list is ever mutated (even accidentally), it will affect all future calls. Prefer a tuple constant orqueues: Sequence[str] | None = Noneand set a default inside the function.
api/common/redis_manager.py:140 - Same mutable-default issue for
queueshere; prefer an immutable default (tuple) orNone+ assignment inside the function.
api/common/redis_manager.py:142 - Docstring typo: "task logic" reads like a copy/paste error; it should refer to the task "id" (or "task message") being searched for in Redis.
api/common/redis_manager.py:5 - Import of 'Any' is not used.
…lied. Removed the extra try check in texts
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.
No description provided.