Room abstraction over NATS JetStream for game backends
Context
Designing Pulse — the backend layer for an unannounced tycoon sim. Needed session semantics, pub/sub messaging, and a path to multiplayer without standing up bespoke game-server infrastructure.
Decision
Implement rooms as a thin abstraction on top of NATS JetStream streams and consumers. Game clients join a room; Pulse routes messages and presence through stream subjects.
Alternatives Considered
Dedicated game server with WebSockets
Pros
- Full control over protocol
Cons
- More ops and protocol design for a solo project
Off-the-shelf multiplayer backend
Pros
- Fast to integrate
Cons
- Ongoing cost and less alignment with contract-stack skills
Raw JetStream without room layer
Pros
- Simplest initial code
Cons
- Leaks stream topology into game logic
Reasoning
I already use NATS JetStream on contract backends. A room layer keeps game code ignorant of subject naming and consumer topology, and reuses durable streams for replay and debugging. Same patterns as analytics ingestion, different payload.