MCPcopy Index your code
hub / github.com/coder/coder / WatchAllWorkspaceBuilds

Method WatchAllWorkspaceBuilds

codersdk/workspaces.go:861–896  ·  view source on GitHub ↗

WatchAllWorkspaceBuilds watches for workspace build updates across all workspaces. This requires the workspace-build-updates experiment to be enabled. The returned decoder should be closed by calling Close() when done to properly clean up the WebSocket connection.

(ctx context.Context)

Source from the content-addressed store, hash-verified

859// The returned decoder should be closed by calling Close() when done to properly
860// clean up the WebSocket connection.
861func (c *Client) WatchAllWorkspaceBuilds(ctx context.Context) (*wsjson.Decoder[WorkspaceBuildUpdate], error) {
862 ctx, span := tracing.StartSpan(ctx)
863 defer span.End()
864
865 serverURL, err := c.URL.Parse("/api/experimental/watch-all-workspacebuilds")
866 if err != nil {
867 return nil, xerrors.Errorf("parse url: %w", err)
868 }
869
870 jar, err := cookiejar.New(nil)
871 if err != nil {
872 return nil, xerrors.Errorf("create cookie jar: %w", err)
873 }
874 jar.SetCookies(serverURL, []*http.Cookie{{
875 Name: SessionTokenCookie,
876 Value: c.SessionToken(),
877 }})
878 httpClient := &http.Client{
879 Jar: jar,
880 Transport: c.HTTPClient.Transport,
881 }
882
883 conn, res, err := websocket.Dial(ctx, serverURL.String(), &websocket.DialOptions{
884 HTTPClient: httpClient,
885 CompressionMode: websocket.CompressionDisabled,
886 })
887 if err != nil {
888 if res == nil {
889 return nil, err
890 }
891 return nil, ReadBodyAsError(res)
892 }
893
894 d := wsjson.NewDecoder[WorkspaceBuildUpdate](conn, websocket.MessageText, c.logger)
895 return d, nil
896}
897
898// WorkspaceAvailableUsers returns users available for workspace creation.
899// This is used to populate the owner dropdown when creating workspaces for

Callers 3

scaletestAutostartMethod · 0.80
TestRunFunction · 0.80

Calls 9

SessionTokenMethod · 0.95
StartSpanFunction · 0.92
ReadBodyAsErrorFunction · 0.85
SetCookiesMethod · 0.80
ParseMethod · 0.65
NewMethod · 0.65
DialMethod · 0.65
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by 2

TestRunFunction · 0.64