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

Method WatchWorkspaceAgentContainers

codersdk/workspaceagents.go:588–620  ·  view source on GitHub ↗
(ctx context.Context, agentID uuid.UUID)

Source from the content-addressed store, hash-verified

586}
587
588func (c *Client) WatchWorkspaceAgentContainers(ctx context.Context, agentID uuid.UUID) (<-chan WorkspaceAgentListContainersResponse, io.Closer, error) {
589 reqURL, err := c.URL.Parse(fmt.Sprintf("/api/v2/workspaceagents/%s/containers/watch", agentID))
590 if err != nil {
591 return nil, nil, err
592 }
593
594 conn, res, err := websocket.Dial(ctx, reqURL.String(), &websocket.DialOptions{
595 // We want `NoContextTakeover` compression to balance improving
596 // bandwidth cost/latency with minimal memory usage overhead.
597 CompressionMode: websocket.CompressionNoContextTakeover,
598 HTTPClient: &http.Client{
599 Transport: c.HTTPClient.Transport,
600 },
601 HTTPHeader: http.Header{
602 SessionTokenHeader: []string{c.SessionToken()},
603 },
604 })
605 if err != nil {
606 if res == nil {
607 return nil, nil, err
608 }
609 return nil, nil, ReadBodyAsError(res)
610 }
611
612 // When a workspace has a few devcontainers running, or a single devcontainer
613 // has a large amount of apps, then each payload can easily exceed 32KiB.
614 // We up the limit to 4MiB to give us plenty of headroom for workspaces that
615 // have lots of dev containers with lots of apps.
616 conn.SetReadLimit(1 << 22) // 4MiB
617
618 d := wsjson.NewDecoder[WorkspaceAgentListContainersResponse](conn, websocket.MessageText, c.logger)
619 return d.Chan(), d, nil
620}
621
622// WorkspaceAgentDeleteDevcontainer deletes the devcontainer with the given ID.
623func (c *Client) WorkspaceAgentDeleteDevcontainer(ctx context.Context, agentID uuid.UUID, devcontainerID string) error {

Callers 1

Calls 6

SessionTokenMethod · 0.95
ReadBodyAsErrorFunction · 0.85
ParseMethod · 0.65
DialMethod · 0.65
StringMethod · 0.45
ChanMethod · 0.45

Tested by 1