MCPcopy
hub / github.com/grafana/dskit / sendKeyNotifications

Method sendKeyNotifications

kv/memberlist/memberlist_client.go:1199–1218  ·  view source on GitHub ↗

sendKeyNotifications sends accumulated notifications to watchers of respective keys.

()

Source from the content-addressed store, hash-verified

1197
1198// sendKeyNotifications sends accumulated notifications to watchers of respective keys.
1199func (m *KV) sendKeyNotifications() {
1200 newNotifs := func() map[string]struct{} {
1201 // Grab and clear accumulated notifications.
1202 m.notifMu.Lock()
1203 defer m.notifMu.Unlock()
1204
1205 if len(m.keyNotifications) == 0 {
1206 return nil
1207 }
1208 newMap := make(map[string]struct{})
1209 m.numberOfKeyNotifications.Set(float64(len(m.keyNotifications)))
1210 notifs := m.keyNotifications
1211 m.keyNotifications = newMap
1212 return notifs
1213 }
1214
1215 for key := range newNotifs() {
1216 m.notifyWatchersSync(key)
1217 }
1218}
1219
1220// notifyWatcherSync immediately sends notification to all watchers of given key.
1221func (m *KV) notifyWatchersSync(key string) {

Callers 2

TestNotificationDelayFunction · 0.95

Calls 2

notifyWatchersSyncMethod · 0.95
SetMethod · 0.65

Tested by 1

TestNotificationDelayFunction · 0.76