Tooling
Realtime
The server bus and presence behind live screens: memory, PostgreSQL or Redis, delivered over SSE.
@krizaka/realtime gives a Node app realtime behind one interface: a bus (publish and subscribe by channel),
presence (who is connected, by heartbeat and time-to-live) and Server-Sent Events. The adapter is a deployment choice —
memory, PostgreSQL LISTEN/NOTIFY or Redis / Valkey — and the code that publishes and subscribes never knows
which.
npm install @krizaka/realtime
npm install pg # for the PostgreSQL adapter (optional)
npm install ioredis # for the Redis / Valkey adapter (optional)| Entry | What |
|---|---|
@krizaka/realtime | RealtimeBus, PresenceStore, createBus, memoryBus, postgresBus, eventStream, sseFrame. No driver is loaded. |
@krizaka/realtime/pg | pgChannel: the PostgreSQL channel, on node-postgres. |
@krizaka/realtime/redis | redisBus and RedisPresence. |
The contract
- Best-effort.
publishnever throws. A durable fact (a message, a bid) lives in the database and is replayed from it — never from the bus. - Small payloads. Ids and small facts; a PostgreSQL NOTIFY is capped at 8 000 bytes.
- Presence is never a database write per beat. A closed connection lingers briefly so a reconnection changes nothing.
- Fail loudly on configuration.
createBusrefuses a bus that cannot work instead of falling back to memory.
On the client, @krizaka/query invalidates what an event touched, so a screen stays live without
polling.