Skip to content

feat: Add pg-boss as an alternative queue provider #4619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arnabk
Copy link

@arnabk arnabk commented Jun 10, 2025

This commit introduces pg-boss as an optional alternative to Redis for background job and queue processing in FlowiseAI.

Key changes:

  • Added pg-boss as a dependency.
  • Created PgBossQueue, PgBossPredictionQueue, and PgBossUpsertQueue classes to implement queue functionality using pg-boss.
  • Updated QueueManager to conditionally initialize Redis-based queues or pg-boss queues based on the QUEUE_PROVIDER environment variable.
    • If QUEUE_PROVIDER is set to pgboss, the system will use the PostgreSQL connection details from the existing database configuration (DATABASE_TYPE, DATABASE_HOST, etc.) or a specific PG_BOSS_DATABASE_URL.
    • If redis (default), the existing BullMQ/Redis implementation is used.
  • BullBoard setup is skipped when pg-boss is the selected provider, as BullBoard is BullMQ-specific.
  • Added documentation for the new QUEUE_PROVIDER environment variable in CONTRIBUTING.md.

This change provides you with the flexibility to leverage your existing PostgreSQL databases for FlowiseAI's background tasks, potentially reducing operational overhead and simplifying deployments, especially for those already using PostgreSQL.

Note: Server-Sent Events (SSE) for real-time updates on predictions are currently tied to the Redis implementation (RedisEventPublisher) and will not work if pg-boss is selected. Future work may involve implementing a pg-boss compatible SSE mechanism (e.g., using pg_notify).

This commit introduces pg-boss as an optional alternative to Redis for background job and queue processing in FlowiseAI.

Key changes:
- Added `pg-boss` as a dependency.
- Created `PgBossQueue`, `PgBossPredictionQueue`, and `PgBossUpsertQueue` classes to implement queue functionality using pg-boss.
- Updated `QueueManager` to conditionally initialize Redis-based queues or pg-boss queues based on the `QUEUE_PROVIDER` environment variable.
    - If `QUEUE_PROVIDER` is set to `pgboss`, the system will use the PostgreSQL connection details from the existing database configuration (`DATABASE_TYPE`, `DATABASE_HOST`, etc.) or a specific `PG_BOSS_DATABASE_URL`.
    - If `redis` (default), the existing BullMQ/Redis implementation is used.
- BullBoard setup is skipped when pg-boss is the selected provider, as BullBoard is BullMQ-specific.
- Added documentation for the new `QUEUE_PROVIDER` environment variable in `CONTRIBUTING.md`.

This change provides you with the flexibility to leverage your existing PostgreSQL databases for FlowiseAI's background tasks, potentially reducing operational overhead and simplifying deployments, especially for those already using PostgreSQL.

Note: Server-Sent Events (SSE) for real-time updates on predictions are currently tied to the Redis implementation (`RedisEventPublisher`) and will not work if `pg-boss` is selected. Future work may involve implementing a pg-boss compatible SSE mechanism (e.g., using `pg_notify`).
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