[pull] main from jsr-io:main#94
Merged
Merged
Conversation
Part of the API service split ([design RFC #1414](#1414)). **Step 4** of the migration sequence: move the first read-only metadata GETs to the workers-rs front. ## What this does Ports `GET /api/stats` and `GET /api/metrics` from the Cloud Run compute service to the `workers-rs` Worker: - **Shared wire types.** Extracts `ApiStats`, `ApiStatsPackage`, `ApiStatsPackageVersion`, and `ApiMetrics` into the shared, wasm-safe `jsr_types` crate (new `jsr_types::api` module). The compute `api` crate now re-exports them, so **both services serialize byte-identical JSON by construction** (parity for these two endpoints). - **Worker DB queries.** Implements `package_stats` and `metrics` in the Worker via `tokio-postgres` over Hyperdrive (no `sqlx`). The SQL is kept verbatim with `Database::package_stats` / `Database::metrics`. - **Routing via axum.** The Worker routes with an `axum::Router` (workers-rs `http` feature) instead of a hand-rolled `worker::Router`, to stay consistent with the compute service's router-based structure. `/api/stats` and `/api/metrics` are served by the Worker; the unmatched fallback returns `501 Not Implemented`. ## Scope / non-goals - The Worker is **not yet fronting prod traffic** — the `lb` routing cutover is step 8. - The compute side keeps serving these endpoints too; nothing is removed until the cleanup step. - Compute keeps using routerify (it builds on the hyper server + tokio runtime, which don't compile to wasm). Converging compute onto axum is a separate, optional refactor — not in this PR. - The proxy-to-compute fallback (replacing the 501) and the larger metadata GETs (`/api/packages`, `/api/users/:id`, package/scope/version metadata) follow in subsequent PRs. ## Verification - `cargo build --target wasm32-unknown-unknown --release` (workers-rs) — green - `cargo clippy --target wasm32-unknown-unknown -- -D warnings` (workers-rs) — green - `cargo fmt --check` (workers-rs) — green - `cargo build -p jsr_types --target wasm32-unknown-unknown` (default features, no sqlx) — green - `cargo check -p registry_api` (compute, `SQLX_OFFLINE`) — green
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )