Phase 3a: HTTP API + server foundation#6
Merged
Merged
Conversation
Implements the HTTP control surface package: api.New wires a Go 1.22
method+path ServeMux; enqueue handler (POST /api/queues/{queue}/jobs)
returns 201, 400, 409, or 500; jobView, toJobView, parseInt64 helpers
defined for Tasks 6-7; stats/listDLQ/requeueDLQ/queues are 501 stubs.
Tests use Redis DB 12 and skip when Redis is unreachable.
Update CLAUDE.md to reflect the shipped HTTP API package and server: status, "what exists today" bullets, new broker methods and requeue.lua script, DLQ table row, layout tree, build order, known-limitations (API/auth/payload/paging caveats), DB allocation (api → DB 12), and end-to-end run commands.
Owner
Author
Code reviewNo 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 👎. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First Phase 3 sub-project: a JSON HTTP API and an always-on server, plus the broker methods they need. The foundation the dashboard (3b) and producer SDK (3c) will consume. No queue dependency added — routing is stdlib
net/http(1.22 method+path patterns); the only state transition introduced (requeue) is a single atomic Lua script.internal/broker— new read/admin methods:Stats(per-queue depth by state via one ZCARD×3+LLEN pipeline),ListDLQ(paged dead-letter inspection),RequeueDLQ(atomicrequeue.lua: dlq→ready, resetting attempts to 0, ready-score rebuilt from priority exactly like promote/reaper), andQueues(SCAN-based discovery, deduped + sorted).internal/api(new) — stdlibnet/httpJSON handler:POST /api/queues/{queue}/jobs(enqueue;409on idempotency-key duplicate),GET …/stats,GET …/dlq?limit=&offset=,POST …/dlq/{id}/requeue(404if not in DLQ),GET /api/queues.{"error":…}envelope; empty lists serialize as[]notnull.cmd/server(new) — wires Redis + broker (with a Phase 2metrics.Recorder, so API enqueues are counted) + the API handler +/metrics(depth gauges for-queues) +/healthz, with graceful shutdown. Flags-addr,-redis,-queues.Design & plan
docs/superpowers/specs/2026-06-08-relay-phase3a-http-api-design.mddocs/superpowers/plans/2026-06-08-relay-phase3a-http-api.mdTest plan
go build ./...,go vet ./...,gofmt -l internal/ cmd/all cleango test -race ./...(uncached) — broker (DB 15), worker (DB 14), metrics (DB 13), api (DB 12), job all pass against a real Redis; test DBs isolated sogo test ./...is parallel-safehttptestcover 201/409/400/404/200, empty-list shape, and the full DLQ→requeue→ready flowcmd/serversmoke-tested end-to-end (healthz, enqueue, stats, queues, /metrics)