mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +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:
22
pubsub.go
22
pubsub.go
@ -435,18 +435,16 @@ func (c *PubSub) newMessage(reply interface{}) (interface{}, error) {
|
||||
}, nil
|
||||
default:
|
||||
// Try to handle as generic push notification
|
||||
if c.pushProcessor.IsEnabled() {
|
||||
ctx := c.getContext()
|
||||
registry := c.pushProcessor.GetRegistry()
|
||||
if registry != nil {
|
||||
handled := registry.HandleNotification(ctx, reply)
|
||||
if handled {
|
||||
// Return a special message type to indicate it was handled
|
||||
return &PushNotificationMessage{
|
||||
Command: kind,
|
||||
Args: reply[1:],
|
||||
}, nil
|
||||
}
|
||||
ctx := c.getContext()
|
||||
registry := c.pushProcessor.GetRegistry()
|
||||
if registry != nil {
|
||||
handled := registry.HandleNotification(ctx, reply)
|
||||
if handled {
|
||||
// Return a special message type to indicate it was handled
|
||||
return &PushNotificationMessage{
|
||||
Command: kind,
|
||||
Args: reply[1:],
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("redis: unsupported pubsub message: %q", kind)
|
||||
|
Reference in New Issue
Block a user