swap-realtime
Move live UI updates off the shared Redis (a dedicated Redis, NATS, a hosted pub/sub). Use when the user decides realtime fan-out should leave the main Redis, or asks how live updates scale. Not for d
Files1
View on GitHubSKILL.md.claude/skills/swap-realtime/SKILL.md
GitHubSwap the realtime transport
- Seam:
createRealtime(schema)inpackages/nest-common/src/realtime.tsreturnspublish(redis, channel, message)andRealtimeHub(one subscriber connection per API process, fanned out to its SSE streams). There is no separate interface: the connection passed in is the swap point. - Today: Redis pub/sub on the shared
REDIS_URL, channelsrealtime:user:<id>andrealtime:org:<id>. Best effort: messages only say "refetch". - Used in:
apps/api/src/realtime.ts(hub and publish),apps/worker/src/realtime/(publishes domain events fromevents-realtime), andapps/ai/app/realtime.py(Python publisher, same prefix and message contract).
Swap
- A dedicated Redis: give
RealtimeHuband everypublishcall a connection to it, from a new variable (e.g.REALTIME_REDIS_URL) in the api's and worker'ssrc/env.tsandapps/ai/app/settings.py, documented in.env.exampleanddocs/environment.md. Nothing else changes. - Another broker: reimplement
createRealtimewith the samepublishandRealtimeHub.streamsignatures, and changeapps/ai/app/realtime.pyto publish there too. Keep channel names and therealtimeMessagecontract (packages/contracts/src/realtime.ts).
Tests
packages/nest-common/test/realtime.integration.test.ts,
apps/worker/src/realtime/realtime.processor.test.ts, the realtime case in
apps/api/test/api.integration.test.ts, and apps/web/e2e/realtime.spec.ts.
Finish
- The verify skill.
- Ask the
revieweragent to review the change, and thesecurity-revieweragent: a new implementation brings its own credentials and sends data somewhere new. If you wrote a migration, themigration-revieweragent too. - Update the seam's row in the README's "Scaling path" table if what's "Now" changed.