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:
36
internal/pushnotif/types.go
Normal file
36
internal/pushnotif/types.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user