Skip to content

feat: namespace-based routing for multi-tenant isolation#31

Merged
pratyush618 merged 3 commits intomasterfrom
feat/namespace-routing
Mar 21, 2026
Merged

feat: namespace-based routing for multi-tenant isolation#31
pratyush618 merged 3 commits intomasterfrom
feat/namespace-routing

Conversation

@pratyush618
Copy link
Copy Markdown
Collaborator

Summary

  • Namespace routing: Queue(namespace="team-a") isolates workloads — enqueued jobs carry the namespace, workers only dequeue matching jobs, inspection methods scope to the namespace by default
  • Full-stack implementation: Storage trait, all 3 backends (SQLite, Postgres, Redis), scheduler, PyO3 bindings, Python Queue class, type stubs
  • DLQ & archival preservation: dead_letter and archived_jobs tables gain namespace column; namespace survives DLQ move and retry
  • Backward compatible: None namespace only sees NULL-namespace jobs — existing users unaffected

Test plan

  • cargo test --workspace — 43 Rust tests pass
  • cargo check with all feature combos (default, postgres, redis, native-async)
  • uv run python -m pytest tests/python/ -v — 350 pass (5 new namespace tests), 8 skipped
  • uv run ruff check py_src/ tests/ — clean
  • uv run mypy py_src/taskito/ --no-incremental — 0 errors (77 files)
  • New test_namespace.py: enqueue sets namespace, None for unnamespaced, worker isolation, list_jobs scoping, result preservation

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.
@pratyush618 pratyush618 merged commit 1669231 into master Mar 21, 2026
10 checks passed
@pratyush618 pratyush618 deleted the feat/namespace-routing branch March 31, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant