MCPcopy Create free account
hub / github.com/coder/coder / appClientConn

Function appClientConn

scaletest/workspacetraffic/conn.go:272–289  ·  view source on GitHub ↗
(ctx context.Context, client *codersdk.Client, url string)

Source from the content-addressed store, hash-verified

270}
271
272func appClientConn(ctx context.Context, client *codersdk.Client, url string) (*countReadWriteCloser, error) {
273 wsOptions := &websocket.DialOptions{
274 HTTPClient: client.HTTPClient,
275 }
276 client.SessionTokenProvider.SetDialOption(wsOptions)
277
278 //nolint:bodyclose // The websocket conn manages the body.
279 conn, _, err := websocket.Dial(ctx, url, wsOptions)
280 if err != nil {
281 return nil, xerrors.Errorf("websocket dial: %w", err)
282 }
283
284 netConn := websocketNetConn(conn, websocket.MessageBinary)
285
286 // Wrap the conn in a countReadWriteCloser so we can monitor bytes sent/rcvd.
287 crw := &countReadWriteCloser{rwc: netConn}
288 return crw, nil
289}
290
291// wsNetConn wraps net.Conn created by websocket.NetConn(). Cancel func
292// is called if a read or write error is encountered.

Callers 1

RunMethod · 0.85

Calls 4

websocketNetConnFunction · 0.85
SetDialOptionMethod · 0.65
DialMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected