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

Method sendAgentUpdate

vpn/tunnel.go:556–584  ·  view source on GitHub ↗

sendAgentUpdate sends a peer update message to the manager with the current state of the agents, including the latest network status.

()

Source from the content-addressed store, hash-verified

554// sendAgentUpdate sends a peer update message to the manager with the current
555// state of the agents, including the latest network status.
556func (u *updater) sendAgentUpdate() {
557 u.mu.Lock()
558 defer u.mu.Unlock()
559
560 agents := make([]*agentWithPing, 0, len(u.agents))
561 for _, agent := range u.agents {
562 agents = append(agents, &agent)
563 }
564 upsertedAgents := u.convertAgentsLocked(agents)
565 if len(upsertedAgents) == 0 {
566 return
567 }
568
569 u.logger.Debug(u.ctx, "sending agent update")
570
571 msg := &TunnelMessage{
572 Msg: &TunnelMessage_PeerUpdate{
573 PeerUpdate: &PeerUpdate{
574 UpsertedAgents: upsertedAgents,
575 },
576 },
577 }
578
579 select {
580 case <-u.ctx.Done():
581 return
582 case u.uSendCh <- msg:
583 }
584}
585
586func (u *updater) netStatusLoop() {
587 ticker := u.clock.NewTicker(netStatusInterval)

Callers 1

netStatusLoopMethod · 0.95

Calls 4

convertAgentsLockedMethod · 0.95
LockMethod · 0.45
UnlockMethod · 0.45
DoneMethod · 0.45

Tested by

no test coverage detected