mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
refactor: remove unnecessary enabled field and IsEnabled/SetEnabled methods
- Remove enabled field from PushNotificationProcessor struct - Remove IsEnabled() and SetEnabled() methods from processor interface - Remove enabled parameter from NewPushNotificationProcessor() - Update all interfaces in pool package to remove IsEnabled requirement - Simplify processor logic - if processor exists, it works - VoidPushNotificationProcessor handles disabled case by discarding notifications - Update all tests to use simplified interface without enable/disable logic Benefits: - Simpler, cleaner interface with less complexity - No unnecessary state management for enabled/disabled - VoidPushNotificationProcessor pattern handles disabled case elegantly - Reduced cognitive overhead - processors just work when set - Eliminates redundant enabled checks throughout codebase - More predictable behavior - set processor = it works
This commit is contained in:
4
redis.go
4
redis.go
@ -535,7 +535,7 @@ func (c *baseClient) _process(ctx context.Context, cmd Cmder, attempt int) (bool
|
||||
}
|
||||
if err := cn.WithReader(c.context(ctx), c.cmdTimeout(cmd), func(rd *proto.Reader) error {
|
||||
// Check for push notifications before reading the command reply
|
||||
if c.opt.Protocol == 3 && c.pushProcessor.IsEnabled() {
|
||||
if c.opt.Protocol == 3 {
|
||||
if err := c.pushProcessor.ProcessPendingNotifications(ctx, rd); err != nil {
|
||||
internal.Logger.Printf(ctx, "push: error processing push notifications: %v", err)
|
||||
}
|
||||
@ -818,7 +818,7 @@ func (c *Client) initializePushProcessor() {
|
||||
c.pushProcessor = c.opt.PushNotificationProcessor
|
||||
} else if c.opt.PushNotifications {
|
||||
// Create default processor when push notifications are enabled
|
||||
c.pushProcessor = NewPushNotificationProcessor(true)
|
||||
c.pushProcessor = NewPushNotificationProcessor()
|
||||
} else {
|
||||
// Create void processor when push notifications are disabled
|
||||
c.pushProcessor = NewVoidPushNotificationProcessor()
|
||||
|
Reference in New Issue
Block a user