satellite/nodeevents: deduplicate node IDs
Remove dupulicate node IDs when sending notifications. Change-Id: I76c642e342081f8fdf8248443de8383b9e88eed2
This commit is contained in:
parent
f733cb255b
commit
38275bd710
@ -69,8 +69,13 @@ func (c *CustomerioNotifier) Notify(ctx context.Context, satellite string, event
|
||||
}
|
||||
|
||||
var nodeIDs string
|
||||
idsMap := make(map[string]struct{})
|
||||
for _, e := range events {
|
||||
nodeIDs = nodeIDs + e.NodeID.String() + ","
|
||||
idStr := e.NodeID.String()
|
||||
if _, ok := idsMap[idStr]; !ok {
|
||||
idsMap[idStr] = struct{}{}
|
||||
nodeIDs = nodeIDs + idStr + ","
|
||||
}
|
||||
}
|
||||
nodeIDs = strings.TrimSuffix(nodeIDs, ",")
|
||||
|
||||
|
@ -28,8 +28,13 @@ func (m *MockNotifier) Notify(ctx context.Context, satellite string, events []No
|
||||
if len(events) == 0 {
|
||||
return nil
|
||||
}
|
||||
idsMap := make(map[string]struct{})
|
||||
for _, e := range events {
|
||||
nodeIDs = nodeIDs + e.NodeID.String() + ","
|
||||
idStr := e.NodeID.String()
|
||||
if _, ok := idsMap[idStr]; !ok {
|
||||
idsMap[idStr] = struct{}{}
|
||||
nodeIDs = nodeIDs + idStr + ","
|
||||
}
|
||||
}
|
||||
nodeIDs = strings.TrimSuffix(nodeIDs, ",")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user