Skip to content

Bulk enqueue (count-based) + dashboard Count field#11

Merged
StrangeNoob merged 7 commits into
mainfrom
bulk-enqueue
Jun 9, 2026
Merged

Bulk enqueue (count-based) + dashboard Count field#11
StrangeNoob merged 7 commits into
mainfrom
bulk-enqueue

Conversation

@StrangeNoob

Copy link
Copy Markdown
Owner

Summary

Single-at-a-time enqueues don't move the dashboard charts. This adds bulk enqueue (one request → many jobs) so a click produces a visible traffic spike. The sacred scripts are untouched — enqueue.lua/claim.lua are byte-identical to base, no new Go dependency, at-least-once preserved (no exactly-once claims).

  • broker.EnqueueBulk(ctx, jobs, opts...) (int, error) — pipelines the existing enqueue.lua for N jobs in one Redis round-trip (no dedup; each job distinct by id). Pre-loads the script (enqueueScript.Load) so pipelined EVALSHA can't NOSCRIPT; increments the enqueued metric per job after a successful Exec; empty slice is a no-op.
  • POST /api/queues/{queue}/jobs/bulk (internal/api/bulk.go) — {count, payload, priority?, delay_ms?}201 {enqueued, state}; count capped 1–10000 (400 otherwise). Single POST .../jobs unchanged.
  • client.EnqueueBulk(...) (BulkResult, error) — SDK method; idempotency option ignored (bulk has no dedup).
  • Dashboard: a Count field on the enqueue form (default 1; >1 → bulk burst), with a tested clampCount helper clamping to the server's 1–10000.

Once merged, Railway auto-deploys; the burst control is live at https://relay.prateekm.dev (and the *.up.railway.app URL).

Design & plan

  • Spec: docs/superpowers/specs/2026-06-09-relay-bulk-enqueue-design.md
  • Plan: docs/superpowers/plans/2026-06-09-relay-bulk-enqueue.md

Test plan

  • go build ./..., go vet ./..., gofmt -l internal/ cmd/ clean; go test -race ./... — all packages pass against real Redis (broker 15 / worker 14 / metrics 13 / api 12 / client 11)
  • broker: EnqueueBulk 50→ready, delay→delayed, nil→noop
  • api: bulk of 50 → 201 + stats 50; count 0/10001 → 400; delay_ms → state delayed
  • client: hermetic (body carries count, decodes BulkResult) + wire-compat round-trip (EnqueueBulk → real api/broker → Stats.Ready==25)
  • web: clampCount unit tests; tsc/vitest/vite build; committed web/dist in sync
  • enqueue.lua/claim.lua unchanged; no new Go dependency

Registers the bulk-enqueue route on the ServeMux and implements the
handler in a dedicated bulk.go. Validates count (1–10000 → 400 otherwise),
builds distinct job.Job values from one payload template, delegates to
broker.EnqueueBulk, and responds 201 with {enqueued, state}. Three new
tests (happy path, bad count, delayed state) followed TDD: RED then GREEN.
TDD: red/green clampCount helper in src/lib/count.ts; enqueueBulk added to
src/api.ts; EnqueueForm updated to route count>1 through the bulk endpoint
and count==1 through the existing single-job path. web/dist rebuilt.
@StrangeNoob

Copy link
Copy Markdown
Owner Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@StrangeNoob StrangeNoob merged commit c2f3404 into main Jun 9, 2026
4 checks passed
@StrangeNoob StrangeNoob deleted the bulk-enqueue branch June 9, 2026 09:37
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