sendAgentUpdate sends a peer update message to the manager with the current state of the agents, including the latest network status.
()
| 554 | // sendAgentUpdate sends a peer update message to the manager with the current |
| 555 | // state of the agents, including the latest network status. |
| 556 | func (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 | |
| 586 | func (u *updater) netStatusLoop() { |
| 587 | ticker := u.clock.NewTicker(netStatusInterval) |
no test coverage detected