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§
- WsOpen
Target - The single connection-transfer target a
from websocketon openresolves to: the agent that will host the connection, and the key expression addressing the instance (Room(roomId)→ agentRoom, keyroomId).
Enums§
- WsOpen
Key - #2959: how the key of the single connection transfer addresses its Durable
Object. On Workers the edge (
compose.ts) resolves the hosting instance before theon openbody runs, so the key has to be something it can evaluate there on its own: a route parameter (validated from the upgrade URL), aconstof the context (a pure static initialiser,handlers.Name()) or of a commons ituses(imported intocompose.ts, #2967), or a literal. Anything else — alet-bound local, a field access, a call — isWsOpenKey::Otherand rejected on Workers (bynk.ws.open_transfer_key). - WsOpen
Shape - The shape of an
on openbody’s connection handling (D2).
Constants§
- CONNECTION_
BINDING - The synthetic name of the held connection an
on openhandler receives.
Functions§
- analyse_
open_ shape - Analyse a
from websocketon openbody: find the top-level agent transfers of theconnectionbinding (alet _ <- Agent(key).m(…, connection)statement). A transfer nested in a conditional is deliberately not counted — the host DO must be statically resolvable. - classify_
open_ key - Classify
key, the key ofopen’s connection transfer.is_constanswers whether a name is a constant visible in the context (crate::consts::visible_consts). A parameter shadows a constant of the same name, and a name any top-levelletof the body binds is a local, not the constant (or parameter) it may shadow; so is one aparblock binds, since its bindings land in the enclosing scope.