mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +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:
@ -182,10 +182,13 @@ func TestClientWithoutPushNotifications(t *testing.T) {
|
||||
})
|
||||
defer client.Close()
|
||||
|
||||
// Push processor should be nil
|
||||
// Push processor should be a VoidPushNotificationProcessor
|
||||
processor := client.GetPushNotificationProcessor()
|
||||
if processor != nil {
|
||||
t.Error("Push notification processor should be nil when disabled")
|
||||
if processor == nil {
|
||||
t.Error("Push notification processor should never be nil")
|
||||
}
|
||||
if processor.IsEnabled() {
|
||||
t.Error("Push notification processor should be disabled when PushNotifications is false")
|
||||
}
|
||||
|
||||
// Registering handlers should not panic
|
||||
|
Reference in New Issue
Block a user