sendUpdateResponse responds to the provided `ManagerMessage_GetPeerUpdate` request with the current state of the workspaces.
(req *request[*TunnelMessage, *ManagerMessage])
| 384 | // sendUpdateResponse responds to the provided `ManagerMessage_GetPeerUpdate` request |
| 385 | // with the current state of the workspaces. |
| 386 | func (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. |
no test coverage detected