Public: anyone can read this; the crew can change it.

Is the hub up and what will it take: GET /api/status, and the same numbers on the page #60

cancelled cancelled by trevato opened this
opened this

Other apps are about to depend on relay being up (#15, #16, and any crew that copies client/relay.ts). Today the only way to ask "is the hub alive and taking events" is to fetch the HTML page and read it, and the only way to know what it will accept is to read this repository.

Done looks like

  • [ ] GET /api/status answers a small, flat JSON object in a few milliseconds, from counts the database can give cheaply: { ok, env, commit, schema_version, events, oldest_event_at, newest_event_at, apps, streams, limits: { body_max, person_writes, event_kinds… }, retention_days, signing: "relay1", audience }. Every number comes from one indexed query or a constant — never a scan of the event table (max(id), min/max(occurred_at) with the index from #45).
  • [ ] It says nothing private: no app names, no ids, no secrets, no person. An anonymous caller and an admin get the same body, which is why it can be the thing a monitor polls.
  • [ ] ok is a real check, not the constant true: the schema version matches migrations.length and a trivial query succeeds. When it does not, the status is 503 with ok: false and a reason, so a deploy that half-migrated is visible rather than silently serving errors.
  • [ ] It is cheap enough to poll: cache-control: no-store, no allocation of the whole table, and a test asserting the whole response is produced with a bounded number of queries.
  • [ ] The same numbers reach a person: a line in the terminal's header (src/tty.ts) and one sentence in the page footer ("2,481 events from 6 apps, kept 90 days"), both from the same function so they cannot disagree.
  • [ ] docs/adopting.md names it as the way to check which relay you are pointed at before you post — audience and commit are exactly what an adopting crew needs when a key stops verifying (#50).
  • [ ] Tests: the shape, ok: false and 503 on a version mismatch, no identity anywhere in the body, the same answer for anon and admin, and the floor from src/http.ts on it.

Files: src/status.ts, src/status.test.ts, src/routes.ts, src/page.ts, src/tty.ts, docs/adopting.md, README.md

Risks: a status door is a free description of the app to anyone who asks, so decide each field by "would I print this on the page" — counts yes, names no. Do not let it become a second place where limits are written down: import them from where they already live (src/http.ts, src/ration.ts, src/actions.ts) so the answer cannot drift from the behaviour. #26 says it will export a live stream count; if it lands first, read it, and if it has not, leave streams out rather than inventing a second counter.

Suggested: Torque — exact numbers, stated units, and a reason for each one.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs