Source File
registry.go
Belonging Package
github.com/redis/go-redis/v9/push
package pushimport ()// Registry manages push notification handlerstype Registry struct {mu sync.RWMutexhandlers map[string]NotificationHandlerprotected map[string]bool}// NewRegistry creates a new push notification registryfunc () *Registry {return &Registry{handlers: make(map[string]NotificationHandler),protected: make(map[string]bool),}}// RegisterHandler registers a handler for a specific push notification namefunc ( *Registry) ( string, NotificationHandler, bool) error {if == nil {return ErrHandlerNil}.mu.Lock()defer .mu.Unlock()// Check if handler already existsif , := .protected[]; {return ErrHandlerExists()}.handlers[] =.protected[] =return nil}// GetHandler returns the handler for a specific push notification namefunc ( *Registry) ( string) NotificationHandler {.mu.RLock()defer .mu.RUnlock()return .handlers[]}// UnregisterHandler removes a handler for a specific push notification namefunc ( *Registry) ( string) error {.mu.Lock()defer .mu.Unlock()// Check if handler is protectedif , := .protected[]; && {return ErrProtectedHandler()}delete(.handlers, )delete(.protected, )return nil}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |