Skip to content

feat: Add multi-queue namespaces and PostgreSQL storage backend#38

Open
mcollina wants to merge 6 commits intomainfrom
feat/multi-queue-and-pg-storage
Open

feat: Add multi-queue namespaces and PostgreSQL storage backend#38
mcollina wants to merge 6 commits intomainfrom
feat/multi-queue-and-pg-storage

Conversation

@mcollina
Copy link
Member

Summary

  • Named queue namespaces: Added createNamespace(name) to the Storage interface, allowing multiple isolated queues to share a single storage backend. Redis namespaces share the parent's 3 connections with ref-counted connect/disconnect. Memory and File storage create independent instances.
  • PostgreSQL storage backend: New PgStorage using SELECT FOR UPDATE SKIP LOCKED for concurrent dequeue (pg-boss pattern) and LISTEN/NOTIFY for pub/sub notifications. Shares pool/listener across namespaces with ref counting.
  • Queue/Reaper config: Added optional name field that automatically creates a namespaced storage view.

Test plan

  • 38 PgStorage tests passing (enqueue/dequeue, job state, results, errors, workers, notifications, events, atomic operations, leader election, dedup expiry, clear, namespace)
  • 8 multi-queue tests passing (job isolation, dedup isolation, result isolation, status isolation, backward compat, lifecycle)
  • 20 memory-storage + 10 dedup tests still passing (no regressions)

🤖 Generated with Claude Code

mcollina and others added 2 commits March 10, 2026 07:33
Allow multiple named queues to share a single storage backend.
Queue and Reaper accept an optional `name` config, which calls
`storage.createNamespace(name)` to get an isolated view.

RedisStorage namespaces share the parent's 3 Redis clients with
ref-counted connect/disconnect. MemoryStorage returns independent
instances. FileStorage uses subdirectories.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PgStorage uses SELECT FOR UPDATE SKIP LOCKED for concurrent dequeue
(pg-boss pattern) and LISTEN/NOTIFY for pub/sub notifications.
Shares pool/listener connections across namespaces with ref counting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mcollina mcollina requested a review from ShogunPanda March 14, 2026 11:08
Add postgres service container for PgStorage tests in CI.
Update pnpm-lock.yaml with pg optional dependency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mcollina and others added 3 commits March 16, 2026 18:55
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Root connect/disconnect stays idempotent as before. RefCount only
tracks namespace children so existing code that calls connect()
multiple times followed by a single disconnect() still cleans up.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants