MCPcopy
hub / github.com/redis/go-redis / setupNotificationHook

Function setupNotificationHook

maintnotifications/e2e/notiftracker_test.go:529–545  ·  view source on GitHub ↗

setupNotificationHook adds a notification hook to a cluster client nolint:unused // Used in test files

(client *redis.ClusterClient, hook maintnotifications.NotificationHook)

Source from the content-addressed store, hash-verified

527//
528//nolint:unused // Used in test files
529func setupNotificationHook(client *redis.ClusterClient, hook maintnotifications.NotificationHook) {
530 _ = client.ForEachShard(context.Background(), func(ctx context.Context, nodeClient *redis.Client) error {
531 manager := nodeClient.GetMaintNotificationsManager()
532 if manager != nil {
533 manager.AddNotificationHook(hook)
534 }
535 return nil
536 })
537
538 // Also add hook to new nodes
539 client.OnNewNode(func(nodeClient *redis.Client) {
540 manager := nodeClient.GetMaintNotificationsManager()
541 if manager != nil {
542 manager.AddNotificationHook(hook)
543 }
544 })
545}
546
547// setupNotificationHooks adds multiple notification hooks to a regular client
548//

Calls 4

AddNotificationHookMethod · 0.80
ForEachShardMethod · 0.45
OnNewNodeMethod · 0.45

Tested by

no test coverage detected