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

Method sendUpdateResponse

vpn/tunnel.go:386–405  ·  view source on GitHub ↗

sendUpdateResponse responds to the provided `ManagerMessage_GetPeerUpdate` request with the current state of the workspaces.

(req *request[*TunnelMessage, *ManagerMessage])

Source from the content-addressed store, hash-verified

384// sendUpdateResponse responds to the provided `ManagerMessage_GetPeerUpdate` request
385// with the current state of the workspaces.
386func (u *updater) sendUpdateResponse(req *request[*TunnelMessage, *ManagerMessage]) error {
387 u.mu.Lock()
388 defer u.mu.Unlock()
389
390 state, err := u.conn.CurrentWorkspaceState()
391 if err != nil {
392 return xerrors.Errorf("failed to get current workspace state: %w", err)
393 }
394 update := u.createPeerUpdateLocked(state)
395 resp := &TunnelMessage{
396 Msg: &TunnelMessage_PeerUpdate{
397 PeerUpdate: update,
398 },
399 }
400 err = req.sendReply(resp)
401 if err != nil {
402 return xerrors.Errorf("failed to send RPC reply: %w", err)
403 }
404 return nil
405}
406
407// createPeerUpdateLocked creates a PeerUpdate message from a workspace update, populating
408// the network status of the agents.

Callers 1

handleRPCMethod · 0.80

Calls 6

sendReplyMethod · 0.80
CurrentWorkspaceStateMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected