mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
* Add gRPC update debouncing mechanism Implements backpressure handling for peer network map updates to efficiently handle rapid changes. First update is sent immediately, subsequent rapid updates are coalesced, ensuring only the latest update is sent after a 1-second quiet period. * Enhance unit test to verify peer count synchronization with debouncing and timeout handling * Debounce based on type * Refactor test to validate timer restart after pending update dispatch * Simplify timer reset for Go 1.23+ automatic channel draining Remove manual channel drain in resetTimer() since Go 1.23+ automatically drains the timer channel when Stop() returns false, making the select-case pattern unnecessary.
23 lines
688 B
Go
23 lines
688 B
Go
package network_map
|
|
|
|
import (
|
|
"github.com/netbirdio/netbird/shared/management/proto"
|
|
)
|
|
|
|
// MessageType indicates the type of update message for debouncing strategy
|
|
type MessageType int
|
|
|
|
const (
|
|
// MessageTypeNetworkMap represents network map updates (peers, routes, DNS, firewall)
|
|
// These updates can be safely debounced - only the latest state matters
|
|
MessageTypeNetworkMap MessageType = iota
|
|
// MessageTypeControlConfig represents control/config updates (tokens, peer expiration)
|
|
// These updates should not be dropped as they contain time-sensitive information
|
|
MessageTypeControlConfig
|
|
)
|
|
|
|
type UpdateMessage struct {
|
|
Update *proto.SyncResponse
|
|
MessageType MessageType
|
|
}
|