Expand description
tokio-tungstenite-backed client for the studio WS worker channel.
Responsibilities:
- coerce
http(s)://API URLs tows(s)://and append/connect - attach
Authorization: Bearer <token>and thestudio-worker-v1sub-protocol header to the upgrade - map 401 upgrade responses + 4001 close codes to a typed
WsClientError::AuthFailedso the runtime can surface a friendly hint - serialise
WorkerInboundto JSON text frames and parseWorkerOutboundfrom incoming frames - clean shutdown via
WsClient::close() - emit structured
tracingbreadcrumbs (targetstudio_worker::ws::client) at the transport boundary so connect / recv / send failures are never silent. The session discards recv errors in its genericDisconnected(_)arm and fireslet _ = sender.send(...)for accept / reject / fail / completeJson, so this layer is the only place those faults can surface. Mirrors thestudio_worker::httpbreadcrumb contract.
Structs§
- WsClient
- Active worker-side WS session. Cheap to construct, expensive to drop (closes the socket gracefully).
- WsReceiver
- Single-owner receive half. Owned by the session’s reader task.
- WsSender
- Cheap-to-clone send half. All senders share one
Mutexover the underlying sink so writes from heartbeat / log-shipper / engine dispatch tasks are serialised correctly.
Enums§
- WsClient
Error - Errors surfaced by the client. All variants carry just enough context to log a useful warning + to drive the reconnect policy.
Constants§
Functions§
- connect
- Establish the WebSocket session. Sends the upgrade with the bearer token + sub-protocol header and returns a ready-to-use client.
Type Aliases§
- WsResult
- Result wrapper for WS-client operations.