Skip to content

feat: add queue management handlers#1043

Open
ferhatelmas wants to merge 5 commits into
masterfrom
ferhat/admin-queue-management
Open

feat: add queue management handlers#1043
ferhatelmas wants to merge 5 commits into
masterfrom
ferhat/admin-queue-management

Conversation

@ferhatelmas

@ferhatelmas ferhatelmas commented Apr 23, 2026

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

feat

What is the current behavior?

Manual queue management under load while jumping between systems.

What is the new behavior?

Admin app attaches endpoints for listing, backup and restore.
Add a client to attach it via npm scripts.

Additional context

Kind of playbook automation/ease of use.
Disabled orioledb for restore due to targetless on conflict incompatibility, that support isn't really needed.

@coveralls

coveralls commented Apr 23, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 29148700684

Coverage increased (+0.4%) to 79.824%

Details

  • Coverage increased (+0.4%) from the base build.
  • Patch coverage: 29 uncovered changes across 6 files (282 of 311 lines covered, 90.68%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/internal/database/pg-connection.ts 33 22 66.67%
src/internal/queue/overflow.ts 114 108 94.74%
src/scripts/jobs-client.ts 95 89 93.68%
src/http/routes/admin/queue.ts 35 31 88.57%
src/config.ts 2 1 50.0%
src/internal/queue/database.ts 3 2 66.67%
Total (11 files) 311 282 90.68%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 12925
Covered Lines: 10767
Line Coverage: 83.3%
Relevant Branches: 7500
Covered Branches: 5537
Branch Coverage: 73.83%
Branches in Coverage %: Yes
Coverage Strength: 417.27 hits per line

💛 - Coveralls

Comment thread src/scripts/jobs-client.ts Fixed
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
@ferhatelmas ferhatelmas force-pushed the ferhat/admin-queue-management branch from 8d0e084 to db8596c Compare July 10, 2026 19:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds admin-facing queue overflow management capabilities for pg-boss “created” job backlogs, along with an operator CLI (npm scripts) to list backlog hotspots, archive (“backup”) created jobs into an overflow table, and restore them in controlled batches.

Changes:

  • Added QueueOverflowStorePg with SQL-backed list/count/backup/restore operations and associated unit/integration tests.
  • Exposed new admin endpoints under /queue/overflow, /queue/overflow/count, /queue/overflow/backup, and /queue/overflow/restore with request schemas and disconnect-aware abort handling.
  • Added an operator CLI (jobs-client.ts) + docs and wired npm scripts; refactored pprof-client.ts to reuse shared integer parsers.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/test/admin-queue-overflow.test.ts Integration coverage for admin queue overflow routes against a real pg-boss schema/tables.
src/scripts/README.md Operator documentation for the jobs CLI and endpoint semantics.
src/scripts/pprof-client.ts Reuses shared integer parsing helpers from @internal/parser.
src/scripts/jobs-client.ts New CLI for listing/backing up/restoring created-job overflow via the admin API.
src/scripts/jobs-client.test.ts Unit tests for CLI config parsing, request building, and restore throttling/backoff behavior.
src/internal/queue/queue.ts Moves PG_BOSS_SCHEMA to constants and types Queue.getDb() as QueueDB.
src/internal/queue/overflow.ts New queue overflow store implementing list/count/backup/restore with transactional + advisory-lock semantics.
src/internal/queue/overflow.test.ts Unit tests validating filter normalization, SQL shapes, transaction/abort behavior, and move/restore semantics.
src/internal/queue/index.ts Exports the new overflow module from the queue package.
src/internal/queue/database.ts Adds beginTransaction() to QueueDB to support transactional maintenance operations.
src/internal/queue/constants.ts Adds PG_BOSS_SCHEMA constant to shared queue constants.
src/internal/parser/string-list.ts New helpers for normalizing string lists and parsing comma-separated env/query values.
src/internal/parser/string-list.test.ts Tests for list normalization and comma-separated parsing behavior.
src/internal/parser/integer.ts New strict integer parsers for non-negative and positive safe integers.
src/internal/parser/integer.test.ts Tests for integer parsing strictness and bounds.
src/internal/parser/index.ts Barrel export for new parser utilities.
src/internal/parser/boolean.ts New strict optional-boolean parser used by the jobs CLI.
src/internal/parser/boolean.test.ts Tests for optional-boolean parsing behavior.
src/internal/database/pg-connection.ts Extends beginTransaction options to include abort signals; adds signal-aware pool checkout helper.
src/internal/database/pg-connection.test.ts Tests for signal-aware transaction checkout and late-client release behavior.
src/http/routes/admin/queue.ts Adds admin endpoints + JSON schemas for queue overflow list/count/backup/restore routes.
src/http/routes/admin/queue.test.ts Ensures config initialization order for existing admin queue route tests.
package.json Adds npm scripts for the jobs CLI (list/backup/restore).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated no new comments.

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.

Comment thread src/test/admin-queue-overflow.test.ts
Comment thread src/http/routes/admin/queue.ts
Comment thread src/scripts/README.md
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated no new comments.

@ferhatelmas ferhatelmas marked this pull request as ready for review July 10, 2026 21:06
@ferhatelmas ferhatelmas requested a review from a team as a code owner July 10, 2026 21:06
Comment thread src/internal/strings/boolean.test.ts
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.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.

5 participants