1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

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
This commit is contained in:
Nedyalko Dyakov
2025-06-27 14:03:50 +03:00
parent d3f61973c1
commit e6c5590255

View File

@ -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()
}