1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

refactor: move push notification logic to pusnotif package

This commit is contained in:
Nedyalko Dyakov
2025-06-27 16:27:23 +03:00
parent 9a7a5c853b
commit ada72cefcd
4 changed files with 398 additions and 215 deletions

View File

@ -0,0 +1,36 @@
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
}
// handlerEntry represents a registered handler with its protection status.
type handlerEntry struct {
handler Handler
protected bool
}