setupNotificationHook adds a notification hook to a cluster client nolint:unused // Used in test files
(client *redis.ClusterClient, hook maintnotifications.NotificationHook)
| 527 | // |
| 528 | //nolint:unused // Used in test files |
| 529 | func 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 | // |
no test coverage detected