mirror of
https://github.com/redis/go-redis.git
synced 2025-07-20 22:42:59 +03:00
feat: add VoidPushNotificationProcessor for disabled push notifications
- Add VoidPushNotificationProcessor that reads and discards push notifications - Create PushNotificationProcessorInterface for consistent behavior - Always provide a processor (real or void) instead of nil - VoidPushNotificationProcessor properly cleans RESP3 push notifications from buffer - Remove all nil checks throughout codebase for cleaner, safer code - Update tests to expect VoidPushNotificationProcessor when disabled Benefits: - Eliminates nil pointer risks throughout the codebase - Follows null object pattern for safer operation - Properly handles RESP3 push notifications even when disabled - Consistent interface regardless of push notification settings - Cleaner code without defensive nil checks everywhere
This commit is contained in:
@ -213,10 +213,13 @@ func TestConnWithoutPushNotifications(t *testing.T) {
|
||||
conn := client.Conn()
|
||||
defer conn.Close()
|
||||
|
||||
// Test GetPushNotificationProcessor returns nil
|
||||
// Test GetPushNotificationProcessor returns VoidPushNotificationProcessor
|
||||
processor := conn.GetPushNotificationProcessor()
|
||||
if processor != nil {
|
||||
t.Error("Conn should not have push notification processor for RESP2")
|
||||
if processor == nil {
|
||||
t.Error("Conn should always have a push notification processor")
|
||||
}
|
||||
if processor.IsEnabled() {
|
||||
t.Error("Push notification processor should be disabled for RESP2")
|
||||
}
|
||||
|
||||
// Test RegisterPushNotificationHandler returns nil (no error)
|
||||
|
Reference in New Issue
Block a user