feat: namespace-based routing for multi-tenant isolation#31
Merged
pratyush618 merged 3 commits intomasterfrom Mar 21, 2026
Merged
feat: namespace-based routing for multi-tenant isolation#31pratyush618 merged 3 commits intomasterfrom
pratyush618 merged 3 commits intomasterfrom
Conversation
Add full namespace support so multiple teams/services can share a single database while isolating their workloads. API: Queue(namespace="team-a") sets the namespace for all enqueued jobs. Workers only dequeue jobs matching their namespace. Inspection methods default to the queue's namespace (pass namespace=None for global view). Changes: - Storage trait: dequeue, dequeue_from, list_jobs, list_jobs_filtered all accept namespace parameter - Diesel backends: namespace filter in SQL WHERE clause (eq or is_null) - Redis backend: post-deserialization namespace check in dequeue loop - Scheduler: carries namespace field, passes to dequeue_from - PyQueue: namespace field on struct, set from Python constructor - PyJob: exposes namespace attribute to Python - DLQ: namespace preserved through move_to_dlq and retry_dead (dead_letter table gains namespace column) - Archival: archived_jobs table gains namespace column, preserved in list_archived - Periodic tasks: inherit namespace from scheduler - Backward compatible: None namespace sees only NULL-namespace jobs
- Add namespace-based routing to 0.7.0 changelog features and internals - Add namespace parameter to Queue constructor docs - Add namespace parameter to list_jobs and list_jobs_filtered docs
0.7.0 is already released. Namespace routing goes into 0.8.0.
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.
Summary
Queue(namespace="team-a")isolates workloads — enqueued jobs carry the namespace, workers only dequeue matching jobs, inspection methods scope to the namespace by defaultdead_letterandarchived_jobstables gainnamespacecolumn; namespace survives DLQ move and retryNonenamespace only seesNULL-namespace jobs — existing users unaffectedTest plan
cargo test --workspace— 43 Rust tests passcargo checkwith all feature combos (default, postgres, redis, native-async)uv run python -m pytest tests/python/ -v— 350 pass (5 new namespace tests), 8 skippeduv run ruff check py_src/ tests/— cleanuv run mypy py_src/taskito/ --no-incremental— 0 errors (77 files)test_namespace.py: enqueue sets namespace, None for unnamespaced, worker isolation, list_jobs scoping, result preservation