Skip to content

Commit e6c5590

Browse files
committed
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
1 parent d3f6197 commit e6c5590

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

sentinel.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ type FailoverOptions struct {
6161
Protocol int
6262
Username string
6363
Password string
64+
65+
// PushNotifications enables push notifications for RESP3.
66+
// Defaults to true for RESP3 connections.
67+
PushNotifications bool
6468
// CredentialsProvider allows the username and password to be updated
6569
// before reconnecting. It should return the current username and password.
6670
CredentialsProvider func() (username string, password string)
@@ -129,6 +133,7 @@ func (opt *FailoverOptions) clientOptions() *Options {
129133
Protocol: opt.Protocol,
130134
Username: opt.Username,
131135
Password: opt.Password,
136+
PushNotifications: opt.PushNotifications,
132137
CredentialsProvider: opt.CredentialsProvider,
133138
CredentialsProviderContext: opt.CredentialsProviderContext,
134139
StreamingCredentialsProvider: opt.StreamingCredentialsProvider,
@@ -426,11 +431,12 @@ func NewFailoverClient(failoverOpt *FailoverOptions) *Client {
426431
}
427432
rdb.init()
428433

429-
// Initialize push notification processor to prevent nil pointer dereference
434+
// Initialize push notification processor similar to regular client
430435
if opt.PushNotificationProcessor != nil {
431436
rdb.pushProcessor = opt.PushNotificationProcessor
437+
} else if opt.PushNotifications {
438+
rdb.pushProcessor = NewPushNotificationProcessor()
432439
} else {
433-
// Create void processor for failover client (typically doesn't need push notifications)
434440
rdb.pushProcessor = NewVoidPushNotificationProcessor()
435441
}
436442

@@ -500,11 +506,12 @@ func NewSentinelClient(opt *Options) *SentinelClient {
500506
},
501507
}
502508

503-
// Initialize push notification processor to prevent nil pointer dereference
509+
// Initialize push notification processor similar to regular client
504510
if opt.PushNotificationProcessor != nil {
505511
c.pushProcessor = opt.PushNotificationProcessor
512+
} else if opt.PushNotifications {
513+
c.pushProcessor = NewPushNotificationProcessor()
506514
} else {
507-
// Create void processor for Sentinel (typically doesn't need push notifications)
508515
c.pushProcessor = NewVoidPushNotificationProcessor()
509516
}
510517

0 commit comments

Comments
 (0)