1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-16 13:21:51 +03:00
Files
go-redis/internal/pushnotif/types.go
2025-06-27 16:27:23 +03:00

37 lines
1.2 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
}
// handlerEntry represents a registered handler with its protection status.
type handlerEntry struct {
handler Handler
protected bool
}