mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
feat: enhance push notification handlers with context information
This commit is contained in:
@ -6,17 +6,32 @@ import (
|
||||
"github.com/redis/go-redis/v9/internal/proto"
|
||||
)
|
||||
|
||||
// HandlerContext provides context information about where a push notification was received.
|
||||
// This allows handlers to make informed decisions based on the source of the notification.
|
||||
type HandlerContext struct {
|
||||
// Client is the Redis client instance that received the notification
|
||||
Client interface{}
|
||||
|
||||
// ConnPool is the connection pool from which the connection was obtained
|
||||
ConnPool interface{}
|
||||
|
||||
// Conn is the specific connection on which the notification was received
|
||||
Conn interface{}
|
||||
}
|
||||
|
||||
// Handler defines the interface for push notification handlers.
|
||||
type Handler interface {
|
||||
// HandlePushNotification processes a push notification.
|
||||
// HandlePushNotification processes a push notification with context information.
|
||||
// The handlerCtx provides information about the client, connection pool, and connection
|
||||
// on which the notification was received, allowing handlers to make informed decisions.
|
||||
// Returns true if the notification was handled, false otherwise.
|
||||
HandlePushNotification(ctx context.Context, notification []interface{}) bool
|
||||
HandlePushNotification(ctx context.Context, handlerCtx *HandlerContext, 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
|
||||
ProcessPendingNotifications(ctx context.Context, handlerCtx *HandlerContext, rd *proto.Reader) error
|
||||
RegisterHandler(pushNotificationName string, handler Handler, protected bool) error
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user