dev-worker: Bootstrapped the warehouse project as a Go module (pcsw/war… #1

Merged
pchapman merged 1 commit from dev-worker/01KYV3F2FVAQC2XZBS1P6F98YS into main 2026-07-30 23:01:02 -05:00
Collaborator

Bootstrapped the warehouse project as a Go module (pcsw/warehouse).

Layout:

  • cmd/warehouse/main.go — server entrypoint: opens the store (schema auto-applies), starts the HTTP server, handles graceful shutdown on SIGINT/SIGTERM.
  • internal/db/ — SQLite metadata store via modernc.org/sqlite (CGO-free) + jmoiron/sqlx.
    • schema.sql (embedded with go:embed) defines buckets, objects, multipart_uploads, parts, access_keys with appropriate indexes/foreign keys; applied idempotently on every startup (IF NOT EXISTS).
    • db.go: Open/Close/applySchema/HasTable; DSN sets foreign_keys, busy_timeout, WAL.
    • models.go: structs + CRUD for buckets and access_keys (with sentinel errors ErrBucketNotFound/ErrAlreadyExists/ErrAccessKeyNotFound).
    • objects.go: PutObject/GetObject/ListObjects/DeleteObject, StartMultipartUpload/GetMultipartUpload/AbortMultipartUpload, AddPart (upsert)/ListParts.
    • db_test.go: covers schema table existence, idempotent schema apply, and full CRUD for buckets, objects (incl. overwrite-demotes-latest), multipart+parts (incl. upsert and cascade-delete on abort), and access keys.
  • internal/server/ — chi router (go-chi/chi/v5) with middleware (RequestID, RealIP, Logger, Recoverer, Timeout); GET /healthz returns 200 XML when the DB/schema is ready, 503 otherwise. server_test.go covers /healthz 200, 404 on unknown routes, nil-store guard, and an end-to-end httptest server start+shutdown.

Verification done locally:

  • go build ./... succeeds.
  • go test ./... passes for internal/db and internal/server.
  • Running the binary and curling /healthz returns HTTP 200 with application/xml; inspecting the persisted db confirms all five tables exist.
  • .gitignore updated to ignore /data/ and *.db files; README updated.

Notes/assumptions:

  • Chose jmoiron/sqlx on top of modernc.org/sqlite for ergonomics; driver stays CGO-free. Assumed acceptable since the mission only mandated modernc.org/sqlite for portability.
  • DB pool pinned to MaxOpenConns=1 to serialize SQLite's single writer (common SQLite practice); noted in comments.
  • Full AWS Signature V4 auth and actual S3 route handlers were intentionally left as future work (router is wired and ready) — the mission scoped this as a bootstrap with /healthz and DB+server tests, which is delivered.

go build ./...

(build succeeded, no output)

go test ./...

?   	pcsw/warehouse/cmd/warehouse	[no test files]
ok  	pcsw/warehouse/internal/db	(cached)
ok  	pcsw/warehouse/internal/server	(cached)

Opened by saga-dev-worker for mission 01KYV3F2FVAQC2XZBS1P6F98YS.

Bootstrapped the warehouse project as a Go module (pcsw/warehouse). Layout: - cmd/warehouse/main.go — server entrypoint: opens the store (schema auto-applies), starts the HTTP server, handles graceful shutdown on SIGINT/SIGTERM. - internal/db/ — SQLite metadata store via modernc.org/sqlite (CGO-free) + jmoiron/sqlx. - schema.sql (embedded with go:embed) defines buckets, objects, multipart_uploads, parts, access_keys with appropriate indexes/foreign keys; applied idempotently on every startup (IF NOT EXISTS). - db.go: Open/Close/applySchema/HasTable; DSN sets foreign_keys, busy_timeout, WAL. - models.go: structs + CRUD for buckets and access_keys (with sentinel errors ErrBucketNotFound/ErrAlreadyExists/ErrAccessKeyNotFound). - objects.go: PutObject/GetObject/ListObjects/DeleteObject, StartMultipartUpload/GetMultipartUpload/AbortMultipartUpload, AddPart (upsert)/ListParts. - db_test.go: covers schema table existence, idempotent schema apply, and full CRUD for buckets, objects (incl. overwrite-demotes-latest), multipart+parts (incl. upsert and cascade-delete on abort), and access keys. - internal/server/ — chi router (go-chi/chi/v5) with middleware (RequestID, RealIP, Logger, Recoverer, Timeout); GET /healthz returns 200 XML when the DB/schema is ready, 503 otherwise. server_test.go covers /healthz 200, 404 on unknown routes, nil-store guard, and an end-to-end httptest server start+shutdown. Verification done locally: - go build ./... succeeds. - go test ./... passes for internal/db and internal/server. - Running the binary and curling /healthz returns HTTP 200 with application/xml; inspecting the persisted db confirms all five tables exist. - .gitignore updated to ignore /data/ and *.db files; README updated. Notes/assumptions: - Chose jmoiron/sqlx on top of modernc.org/sqlite for ergonomics; driver stays CGO-free. Assumed acceptable since the mission only mandated modernc.org/sqlite for portability. - DB pool pinned to MaxOpenConns=1 to serialize SQLite's single writer (common SQLite practice); noted in comments. - Full AWS Signature V4 auth and actual S3 route handlers were intentionally left as future work (router is wired and ready) — the mission scoped this as a bootstrap with /healthz and DB+server tests, which is delivered. ## go build ./... ``` (build succeeded, no output) ``` ## go test ./... ``` ? pcsw/warehouse/cmd/warehouse [no test files] ok pcsw/warehouse/internal/db (cached) ok pcsw/warehouse/internal/server (cached) ``` --- Opened by saga-dev-worker for mission `01KYV3F2FVAQC2XZBS1P6F98YS`.
Layout:
- cmd/warehouse/main.go — server entrypoint: opens the store (schema auto-applies), starts the HTTP server, handles graceful shutdown on SIGINT/SIGTERM.
- internal/db/ — SQLite metadata store via modernc.org/sqlite (CGO-free) + jmoiron/sqlx.
  - schema.sql (embedded with go:embed) defines buckets, objects, multipart_uploads, parts, access_keys with appropriate indexes/foreign keys; applied idempotently on every startup (IF NOT EXISTS).
  - db.go: Open/Close/applySchema/HasTable; DSN sets foreign_keys, busy_timeout, WAL.
  - models.go: structs + CRUD for buckets and access_keys (with sentinel errors ErrBucketNotFound/ErrAlreadyExists/ErrAccessKeyNotFound).
  - objects.go: PutObject/GetObject/ListObjects/DeleteObject, StartMultipartUpload/GetMultipartUpload/AbortMultipartUpload, AddPart (upsert)/ListParts.
  - db_test.go: covers schema table existence, idempotent schema apply, and full CRUD for buckets, objects (incl. overwrite-demotes-latest), multipart+parts (incl. upsert and cascade-delete on abort), and access keys.
- internal/server/ — chi router (go-chi/chi/v5) with middleware (RequestID, RealIP, Logger, Recoverer, Timeout); GET /healthz returns 200 XML when the DB/schema is ready, 503 otherwise. server_test.go covers /healthz 200, 404 on unknown routes, nil-store guard, and an end-to-end httptest server start+shutdown.

Verification done locally:
- go build ./... succeeds.
- go test ./... passes for internal/db and internal/server.
- Running the binary and curling /healthz returns HTTP 200 with application/xml; inspecting the persisted db confirms all five tables exist.
- .gitignore updated to ignore /data/ and *.db files; README updated.

Notes/assumptions:
- Chose jmoiron/sqlx on top of modernc.org/sqlite for ergonomics; driver stays CGO-free. Assumed acceptable since the mission only mandated modernc.org/sqlite for portability.
- DB pool pinned to MaxOpenConns=1 to serialize SQLite's single writer (common SQLite practice); noted in comments.
- Full AWS Signature V4 auth and actual S3 route handlers were intentionally left as future work (router is wired and ready) — the mission scoped this as a bootstrap with /healthz and DB+server tests, which is delivered.
pchapman deleted branch dev-worker/01KYV3F2FVAQC2XZBS1P6F98YS 2026-07-30 23:01:02 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pcsw/warehouse!1
No description provided.