mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
fix: simplify api
This commit is contained in:
@ -38,11 +38,7 @@ func (p *Processor) UnregisterHandler(pushNotificationName string) error {
|
||||
return p.registry.UnregisterHandler(pushNotificationName)
|
||||
}
|
||||
|
||||
// GetRegistryForTesting returns the push notification registry for testing.
|
||||
// This method should only be used by tests.
|
||||
func (p *Processor) GetRegistryForTesting() *Registry {
|
||||
return p.registry
|
||||
}
|
||||
|
||||
|
||||
// ProcessPendingNotifications checks for and processes any pending push notifications.
|
||||
func (p *Processor) ProcessPendingNotifications(ctx context.Context, rd *proto.Reader) error {
|
||||
@ -82,8 +78,17 @@ func (p *Processor) ProcessPendingNotifications(ctx context.Context, rd *proto.R
|
||||
continue
|
||||
}
|
||||
|
||||
// Handle the notification
|
||||
p.registry.HandleNotification(ctx, notification)
|
||||
// Handle the notification directly
|
||||
if len(notification) > 0 {
|
||||
// Extract the notification type (first element)
|
||||
if notificationType, ok := notification[0].(string); ok {
|
||||
// Get the handler for this notification type
|
||||
if handler := p.registry.GetHandler(notificationType); handler != nil {
|
||||
// Handle the notification
|
||||
handler.HandlePushNotification(ctx, notification)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -108,11 +113,7 @@ func (v *VoidProcessor) RegisterHandler(pushNotificationName string, handler Han
|
||||
return fmt.Errorf("cannot register push notification handler '%s': push notifications are disabled (using void processor)", pushNotificationName)
|
||||
}
|
||||
|
||||
// GetRegistryForTesting returns nil for void processor since it doesn't maintain handlers.
|
||||
// This method should only be used by tests.
|
||||
func (v *VoidProcessor) GetRegistryForTesting() *Registry {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// ProcessPendingNotifications for VoidProcessor does nothing since push notifications
|
||||
// are only available in RESP3 and this processor is used when they're disabled.
|
||||
|
Reference in New Issue
Block a user