From e6c5590255b9e269ae7ffbcd9af168c7c761075e Mon Sep 17 00:00:00 2001 From: Nedyalko Dyakov Date: Fri, 27 Jun 2025 14:03:50 +0300 Subject: [PATCH] feat: enable real push notification processors for SentinelClient and FailoverClient - Add PushNotifications field to FailoverOptions struct - Update clientOptions() to pass PushNotifications field to Options - Change SentinelClient and FailoverClient initialization to use same logic as regular Client - Both clients now support real push notification processors when enabled - Both clients use void processors only when explicitly disabled - Consistent behavior across all client types (Client, SentinelClient, FailoverClient) Benefits: - SentinelClient and FailoverClient can now fully utilize push notifications - Consistent API across all client types - Real processors when push notifications are enabled - Void processors only when explicitly disabled - Equal push notification capabilities for all Redis client types --- sentinel.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sentinel.go b/sentinel.go index 948f3c97..b5e6d73b 100644 --- a/sentinel.go +++ b/sentinel.go @@ -61,6 +61,10 @@ type FailoverOptions struct { Protocol int Username string Password string + + // PushNotifications enables push notifications for RESP3. + // Defaults to true for RESP3 connections. + PushNotifications bool // CredentialsProvider allows the username and password to be updated // before reconnecting. It should return the current username and password. CredentialsProvider func() (username string, password string) @@ -129,6 +133,7 @@ func (opt *FailoverOptions) clientOptions() *Options { Protocol: opt.Protocol, Username: opt.Username, Password: opt.Password, + PushNotifications: opt.PushNotifications, CredentialsProvider: opt.CredentialsProvider, CredentialsProviderContext: opt.CredentialsProviderContext, StreamingCredentialsProvider: opt.StreamingCredentialsProvider, @@ -426,11 +431,12 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client { } rdb.init() - // Initialize push notification processor to prevent nil pointer dereference + // Initialize push notification processor similar to regular client if opt.PushNotificationProcessor != nil { rdb.pushProcessor = opt.PushNotificationProcessor + } else if opt.PushNotifications { + rdb.pushProcessor = NewPushNotificationProcessor() } else { - // Create void processor for failover client (typically doesn't need push notifications) rdb.pushProcessor = NewVoidPushNotificationProcessor() } @@ -500,11 +506,12 @@ func NewSentinelClient(opt *Options) *SentinelClient { }, } - // Initialize push notification processor to prevent nil pointer dereference + // Initialize push notification processor similar to regular client if opt.PushNotificationProcessor != nil { c.pushProcessor = opt.PushNotificationProcessor + } else if opt.PushNotifications { + c.pushProcessor = NewPushNotificationProcessor() } else { - // Create void processor for Sentinel (typically doesn't need push notifications) c.pushProcessor = NewVoidPushNotificationProcessor() }