@@ -249,62 +249,6 @@ func (tnh *TrackingNotificationsHook) increaseRelaxedTimeoutCount(notificationTy
249249 }
250250}
251251
252- // setupNotificationHook sets up tracking for both regular and cluster clients with notification hooks
253- func setupNotificationHook (client redis.UniversalClient , hook maintnotifications.NotificationHook ) {
254- if clusterClient , ok := client .(* redis.ClusterClient ); ok {
255- setupClusterClientNotificationHook (clusterClient , hook )
256- } else if regularClient , ok := client .(* redis.Client ); ok {
257- setupRegularClientNotificationHook (regularClient , hook )
258- }
259- }
260-
261- // setupNotificationHooks sets up tracking for both regular and cluster clients with notification hooks
262- func setupNotificationHooks (client redis.UniversalClient , hooks ... maintnotifications.NotificationHook ) {
263- for _ , hook := range hooks {
264- setupNotificationHook (client , hook )
265- }
266- }
267-
268- // setupRegularClientNotificationHook sets up notification hook for regular clients
269- func setupRegularClientNotificationHook (client * redis.Client , hook maintnotifications.NotificationHook ) {
270- maintnotificationsManager := client .GetMaintNotificationsManager ()
271- if maintnotificationsManager != nil {
272- maintnotificationsManager .AddNotificationHook (hook )
273- } else {
274- fmt .Printf ("[TNH] Warning: Maintenance notifications manager not available for tracking\n " )
275- }
276- }
277-
278- // setupClusterClientNotificationHook sets up notification hook for cluster clients
279- func setupClusterClientNotificationHook (client * redis.ClusterClient , hook maintnotifications.NotificationHook ) {
280- ctx := context .Background ()
281-
282- // Register hook on existing nodes
283- err := client .ForEachShard (ctx , func (ctx context.Context , nodeClient * redis.Client ) error {
284- maintnotificationsManager := nodeClient .GetMaintNotificationsManager ()
285- if maintnotificationsManager != nil {
286- maintnotificationsManager .AddNotificationHook (hook )
287- } else {
288- fmt .Printf ("[TNH] Warning: Maintenance notifications manager not available for tracking on node: %s\n " , nodeClient .Options ().Addr )
289- }
290- return nil
291- })
292-
293- if err != nil {
294- fmt .Printf ("[TNH] Warning: Failed to register timeout tracking hooks on existing cluster nodes: %v\n " , err )
295- }
296-
297- // Register hook on new nodes
298- client .OnNewNode (func (nodeClient * redis.Client ) {
299- maintnotificationsManager := nodeClient .GetMaintNotificationsManager ()
300- if maintnotificationsManager != nil {
301- maintnotificationsManager .AddNotificationHook (hook )
302- } else {
303- fmt .Printf ("[TNH] Warning: Maintenance notifications manager not available for tracking on new node: %s\n " , nodeClient .Options ().Addr )
304- }
305- })
306- }
307-
308252func (tnh * TrackingNotificationsHook ) GetAnalysis () * DiagnosticsAnalysis {
309253 return NewDiagnosticsAnalysis (tnh .GetDiagnosticsLog ())
310254}
0 commit comments