mirror of
https://github.com/block/buzz.git
synced 2026-11-07 18:01:06 +00:00
feat(relay): push per-community storage usage to kgoose (#8714)
### Why?
To bill hosted communities for storage in Orb, kgoose needs
per-community storage usage. The relay already computes it in a daily
snapshot, but nothing delivered it anywhere.
## Summary
- Adds opt-in `BUZZ_STORAGE_USAGE_URL`. When it is set, one
leader-elected relay pod checks every 5 minutes for a new storage
snapshot and POSTs it to kgoose's `POST /v1/buzz/storage-usage/record`
(squareup/cash-server#144285) in consecutive batches of up to 50
communities until every community is sent.
- Each batch is `{measured_at, communities: [{community_host,
storage_bytes, storage_objects}]}`. Active communities with no stored
bytes are reported as zero, and re-sends are safe because kgoose bills
each community once per UTC day.
- Retries on 408, 429, 5xx, and transport errors. No migration;
documented in `docs/storage-accounting.md`. kgoose authenticates the
relay as the `buzz` mesh service, so the relay needs mesh egress to
kgoose-builderbot.
### Related issue
None found. Complements #7899 (snapshot history in the DB). Receiving
endpoint: squareup/cash-server#144285.
### Testing
Unit tests cover batching, retry and reject handling, zero-filling, and
a real HTTP delivery that checks the exact kgoose request body. A
Postgres-gated DB test covers the new reads. End to end, a local relay
delivered to a fake endpoint once per new snapshot.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Shu Hui <shu@squareup.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -162,6 +162,13 @@ BUZZ_PUSH_GATEWAY_DELIVERY_URL=https://push.buzz.xyz/v1/deliveries/apns
|
||||
# BUZZ_OPERATOR_LISTENER_TIMEOUT_MS=5000
|
||||
# BUZZ_OPERATOR_LISTENERS=<64-char hex pubkey>:https://listener.example/mentions
|
||||
|
||||
# Optional endpoint that receives each new per-community storage snapshot
|
||||
# written by `buzz-admin storage-snapshot`, in NIP-98 relay-signed POST batches
|
||||
# shaped like kgoose's storage-usage record request. One relay pod checks for a
|
||||
# new snapshot every 5 minutes. Receivers must treat a repeated community and
|
||||
# measured_at as already recorded.
|
||||
# BUZZ_STORAGE_USAGE_URL=https://kgoose.example/cash-app/goose/v1/buzz/storage-usage/record
|
||||
|
||||
# Optional relay-owned KLIPY key. When set, NIP-11 advertises GIF search and
|
||||
# authenticated desktop clients use this relay as the metadata/search proxy.
|
||||
# Keep the real value in your deployment's secret manager; never commit it.
|
||||
|
||||
Reference in New Issue
Block a user