1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-19 11:43:14 +03:00
Files
go-redis/internal/pushnotif/types.go
Nedyalko Dyakov 91805bc506 refactor: remove handlerWrapper and use separate maps in registry
- Remove unnecessary handlerWrapper complexity from push notifications
- Use separate maps for handlers and protection status in registry
- Store handlers directly without indirection layer
- Maintain same instance identity for registered/retrieved handlers
- Preserve all protected handler functionality with cleaner implementation

Changes:
- internal/pushnotif/registry.go: Use separate handlers and protected maps
- push_notifications.go: Remove handlerWrapper, store handlers directly
- Maintain thread-safe operations with simplified code structure

Benefits:
- Reduced memory overhead (no wrapper objects)
- Direct handler storage without type conversion
- Cleaner, more maintainable code
- Same functionality with better performance
- Eliminated unnecessary complexity layer
- Preserved all existing behavior and safety guarantees
2025-06-27 16:38:31 +03:00

31 lines
1.1 KiB
Go

package pushnotif
import (
"context"
"github.com/redis/go-redis/v9/internal/proto"
)
// Handler defines the interface for push notification handlers.
type Handler interface {
// HandlePushNotification processes a push notification.
// Returns true if the notification was handled, false otherwise.
HandlePushNotification(ctx context.Context, notification []interface{}) bool
}
// ProcessorInterface defines the interface for push notification processors.
type ProcessorInterface interface {
GetHandler(pushNotificationName string) Handler
ProcessPendingNotifications(ctx context.Context, rd *proto.Reader) error
RegisterHandler(pushNotificationName string, handler Handler, protected bool) error
}
// RegistryInterface defines the interface for push notification registries.
type RegistryInterface interface {
RegisterHandler(pushNotificationName string, handler Handler, protected bool) error
UnregisterHandler(pushNotificationName string) error
GetHandler(pushNotificationName string) Handler
GetRegisteredPushNotificationNames() []string
HandleNotification(ctx context.Context, notification []interface{}) bool
}