Reduce the peer status notifications (#956)

Reduce the peer status notifications

When receive new network map invoke multiple notifications for 
every single peers. It cause high cpu usage We handle the in a 
batch the peer notification in update network map.

- Remove the unnecessary UpdatePeerFQDN calls in addNewPeer
- Fix notification in RemovePeer function
- Involve FinishPeerListModifications logic
This commit is contained in:
Zoltan Papp
2023-06-19 11:20:34 +02:00
committed by GitHub
parent cb7ecd1cc4
commit dd29f4c01e
3 changed files with 41 additions and 17 deletions

View File

@ -9,13 +9,13 @@ import (
func TestAddPeer(t *testing.T) {
key := "abc"
status := NewRecorder("https://mgm")
err := status.AddPeer(key)
err := status.AddPeer(key, "abc.netbird")
assert.NoError(t, err, "shouldn't return error")
_, exists := status.peers[key]
assert.True(t, exists, "value was found")
err = status.AddPeer(key)
err = status.AddPeer(key, "abc.netbird")
assert.Error(t, err, "should return error on duplicate")
}
@ -23,7 +23,7 @@ func TestAddPeer(t *testing.T) {
func TestGetPeer(t *testing.T) {
key := "abc"
status := NewRecorder("https://mgm")
err := status.AddPeer(key)
err := status.AddPeer(key, "abc.netbird")
assert.NoError(t, err, "shouldn't return error")
peerStatus, err := status.GetPeer(key)