go-redis/redis · error

handler must implement push.NotificationHandler

Error message

handler must implement push.NotificationHandler

What it means

Error "handler must implement push.NotificationHandler" thrown in go-redis/redis.

Solutions

  1. Ensure the value passed as the push notification handler implements the push.NotificationHandler interface (it must have the handler method for the notification type, typically with a pointer receiver)
  2. If the handler is a struct, register it with a pointer (push.RegisterHandler(..., &myHandler{})) so the interface is satisfied

When it happens

Trigger: Thrown at adapters.go:107 when the library encounters an invalid state.

Common situations: Defensively, declare handler types with explicit interface conformance checks (var _ push.NotificationHandler = (*MyHandler)(nil)) so mistakes are caught at compile time.


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /api/errors/eb2c1e6872a9c9f7. Report an issue: GitHub.

Appendix: source

Thrown at adapters.go:107

	return func(ctx context.Context) (net.Conn, error) {
		// Extract network and address from the options
		network := oa.options.Network
		addr := oa.options.Addr
		return baseDialer(ctx, network, addr)
	}
}

// pushProcessorAdapter adapts a push.NotificationProcessor to implement interfaces.NotificationProcessor.
type pushProcessorAdapter struct {
	processor push.NotificationProcessor
}

// RegisterHandler registers a handler for a specific push notification name.
func (ppa *pushProcessorAdapter) RegisterHandler(pushNotificationName string, handler interface{}, protected bool) error {
	if pushHandler, ok := handler.(push.NotificationHandler); ok {
		return ppa.processor.RegisterHandler(pushNotificationName, pushHandler, protected)
	}
	return errors.New("handler must implement push.NotificationHandler")
}

// UnregisterHandler removes a handler for a specific push notification name.
func (ppa *pushProcessorAdapter) UnregisterHandler(pushNotificationName string) error {
	return ppa.processor.UnregisterHandler(pushNotificationName)
}

// GetHandler returns the handler for a specific push notification name.
func (ppa *pushProcessorAdapter) GetHandler(pushNotificationName string) interface{} {
	return ppa.processor.GetHandler(pushNotificationName)
}

View on GitHub (pinned to 36d97525cd)