docs: close the bridge chapter

This commit is contained in:
jubnl
2026-08-11 23:25:22 +02:00
parent a01476f445
commit 04812702ec
12 changed files with 272 additions and 63 deletions
+3 -2
View File
@@ -34,8 +34,9 @@ const HEARTBEAT_INTERVAL = 30_000;
* than an interval nobody stops.
*
* What did NOT move is the socket registry. It stays module-scoped in
* ws-state.ts because out-of-container code (the MCP seam's safeBroadcast,
* auth.bridge's graph) must see the same rooms; see the note there.
* ws-state.ts because out-of-container code (the no-Nest test harnesses,
* the vi.mock'd src/websocket seam) must see the same rooms; see the note
* there.
*
* The wire protocol is unchanged, down to the frame names. TrekWsAdapter maps
* `{ type }` onto @SubscribeMessage, because the stock adapter dispatches on
+1 -1
View File
@@ -4,7 +4,7 @@ import { RealtimeService } from './realtime.service';
/**
* Global so every migrated module can inject RealtimeService without
* re-importing (same rationale as DatabaseModule). The service stays
* stateless and dependency-free so the out-of-container bridges can build it
* stateless and dependency-free so the no-Nest test harnesses can build it
* with a bare `new`.
*
* The transport itself lives in RealtimeGatewayModule, which AppModule imports
+2 -2
View File
@@ -108,8 +108,8 @@ export class TrekWsAdapter extends WsAdapter {
// failures; this one keeps the transport's own errors visible.
server.on('error', (err) => logError(`ws server error: ${err instanceof Error ? err.message : String(err)}`));
// The fan-out primitives reach the live server through here, and so do the
// out-of-container bridges.
// The fan-out primitives reach the live server through here, and so does
// every out-of-container RealtimeService the test harnesses build.
setServer(server);
return server;
}
+7 -7
View File
@@ -6,13 +6,13 @@ import { User } from '../../types';
* The socket registry: rooms, per-socket identity, and the three fan-out
* primitives.
*
* MODULE state, not provider state, and that is load-bearing. Out-of-container
* code still reaches the rooms: the MCP seam's safeBroadcast imports
* src/websocket directly, auth.bridge hand-builds a RealtimeService, and the
* no-Nest test harnesses construct more. If the rooms lived on a provider
* instance, those broadcasts would go to an empty map: no error, no log, just
* a client that stops updating. Same reasoning as the geo throttle cursor and
* the permissions cache.
* MODULE state, not provider state, and that is load-bearing. The no-Nest test
* harnesses hand-build RealtimeService instances (mcp-test-controllers.ts and
* ~60 unit suites), and the 115 vi.mock('src/websocket') seams assert on these
* exact exports. If the rooms lived on a provider instance, an out-of-container
* broadcast would go to an empty map: no error, no log, just a client that
* stops updating. Same reasoning as the geo throttle cursor and the
* permissions cache.
*
* The gateway next door owns the connection lifecycle and the handshake and
* writes into here. This file deliberately knows nothing about auth.