Skip to main content

Module websocket

Module websocket 

Source
Expand description

v0.104 (real-time track slice 3b): shared analysis of a from websocket on open handler for the Workers wire path.

On Workers the upgrade is authenticated at the edge, then forwarded to the Durable Object that hosts the connection — the agent the on open transfers it to. For that routing to be static, the handler must transfer the connection to exactly one agent, by a key derivable from the request (D2). This module finds that single transfer; both the checker (to diagnose a bad shape) and the emitter (to route the upgrade) use it.

Lives in bynk-check (moved here in the compiler-pipeline-review’s Wave 5, batch 5.1) rather than bynk-emit: it depends only on bynk-syntax’s AST and is conceptually checker-side analysis, misfiled under the emitter.

Structs§

WsOpenTarget
The single connection-transfer target a from websocket on open resolves to: the agent that will host the connection, and the key expression addressing the instance (Room(roomId) → agent Room, key roomId).

Enums§

WsOpenShape
The shape of an on open body’s connection handling (D2).

Constants§

CONNECTION_BINDING
The synthetic name of the held connection an on open handler receives.

Functions§

analyse_open_shape
Analyse a from websocket on open body: find the top-level agent transfers of the connection binding (a let _ <- Agent(key).m(…, connection) statement). A transfer nested in a conditional is deliberately not counted — the host DO must be statically resolvable.