Skip to content

Phase 3c: producer SDK (internal/client)#8

Merged
StrangeNoob merged 8 commits into
mainfrom
phase3c-sdk
Jun 8, 2026
Merged

Phase 3c: producer SDK (internal/client)#8
StrangeNoob merged 8 commits into
mainfrom
phase3c-sdk

Conversation

@StrangeNoob

Copy link
Copy Markdown
Owner

Summary

Third Phase 3 sub-project: a small, self-contained Go HTTP SDK for the Relay API so producers can drive the queue without touching Redis. cmd/demo is refactored to consume it — proving the SDK end-to-end and establishing the real producer topology (producer → HTTP API → broker). No new Go dependency (stdlib only); the atomic claim and at-least-once delivery are untouched.

internal/client (new, stdlib only)

  • New(baseURL, ...Option) with WithHTTPClient/WithTimeout (default ~10s).
  • Enqueue(ctx, queue, payload, ...EnqueueOption)WithDelay/WithPriority/WithIdempotencyKey; 409 → ErrDuplicate. Priority is a *int so WithPriority(0) sends priority:0 while an unset priority is omitted (mirrors the API).
  • Stats, ListDLQ, Requeue (404 → ErrNotFound), Queues.
  • Typed errors: sentinels ErrDuplicate/ErrNotFound; *APIError{Status, Message} from the {"error":…} envelope for other non-2xx. A shared do helper handles marshalling, status mapping, and %w wrapping.
  • No broker/job/Redis import — a producer importing the SDK doesn't drag in the queue internals.

cmd/demo (refactor)

Now a pure SDK consumer: -server http://localhost:8080 replaces -redis; it client.New(...) + Enqueues, treating ErrDuplicate as benign. (It now needs cmd/server running.)

Design & plan

  • Spec: docs/superpowers/specs/2026-06-09-relay-phase3c-producer-sdk-design.md
  • Plan: docs/superpowers/plans/2026-06-09-relay-phase3c-producer-sdk.md

Test plan

  • go build ./..., go vet ./..., gofmt -l internal/ cmd/ clean
  • go test -race ./... — all packages pass against a real Redis (client tests on DB 11; broker 15 / worker 14 / metrics 13 / api 12 / client 11 — parallel-safe)
  • Hermetic httptest unit tests: request method/path/body, response decode, and error mapping (409→ErrDuplicate, 404→ErrNotFound, 500→APIError); priority-0-sent vs unset-omitted
  • Wire-compat round-trip: client → api.New(real broker) → Redis proves the client DTOs match the live server JSON (no field drift)
  • internal/client confirmed stdlib-only (go list -deps shows no broker/job/go-redis); go.mod unchanged
  • cmd/demo smoke-tested end-to-end against a running server

@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 2f33b84 into main Jun 8, 2026
3 checks passed
@StrangeNoob StrangeNoob deleted the phase3c-sdk branch June 8, 2026 21:32
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