Documentation ¶
Overview ¶
Package keyspace_notifications对象
Index ¶
- Variables
- type KeyspaceNotification
- func (c *KeyspaceNotification) HanddlerEvent(asyncHanddler bool, evt *NotificationEvent)
- func (c *KeyspaceNotification) IsListening() bool
- func (c *KeyspaceNotification) Listen(asyncHanddler bool) error
- func (c *KeyspaceNotification) RegistHandler(db, key, eventanem string, fn NotificationHanddler) error
- func (c *KeyspaceNotification) StopListening() error
- func (c *KeyspaceNotification) Sync(ctx context.Context, local bool) error
- func (c *KeyspaceNotification) UnRegistHandler(db, key, eventanem string) error
- type NotificationEvent
- type NotificationEventType
- type NotificationHanddler
Constants ¶
This section is empty.
Variables ¶
var ErrNoitificationsAlreadyListened = errors.New("keyspace-notification已经被监听了")
ErrNoitificationsAlreadyListened keyspace-notification已经被监听了
var ErrNoitificationsNotListeningYet = errors.New("keyspace-notification未被监听")
ErrNoitificationsNotListeningYet keyspace-notification未被监听
Functions ¶
This section is empty.
Types ¶
type KeyspaceNotification ¶
type KeyspaceNotification struct { Client redis.UniversalClient Conf string Handdlers map[string][]NotificationHanddler Handdlerslock sync.RWMutex // contains filtered or unexported fields }
KeyspaceNotification 键空间通知的配置
func (*KeyspaceNotification) HanddlerEvent ¶
func (c *KeyspaceNotification) HanddlerEvent(asyncHanddler bool, evt *NotificationEvent)
HanddlerEvent 调用回调函数处理消息 @params asyncHanddler bool 是否异步执行回调函数 @params evt *event.Event 待处理的消息
func (*KeyspaceNotification) IsListening ¶
func (c *KeyspaceNotification) IsListening() bool
func (*KeyspaceNotification) Listen ¶
func (c *KeyspaceNotification) Listen(asyncHanddler bool) error
Listen 监听notification @params asyncHanddler bool 是否并行执行回调
func (*KeyspaceNotification) RegistHandler ¶
func (c *KeyspaceNotification) RegistHandler(db, key, eventanem string, fn NotificationHanddler) error
RegistHandler 将回调函数注册到指定位置上 @params db, key, eventanem string 注册的位置,位置可以是具体的值也可以是*,*表示监听所有消息 @params fn NotificationHanddler 注册到topic上的回调函数
func (*KeyspaceNotification) StopListening ¶
func (c *KeyspaceNotification) StopListening() error
StopListening 停止监听
func (*KeyspaceNotification) Sync ¶
func (c *KeyspaceNotification) Sync(ctx context.Context, local bool) error
Sync 将服务器的设置与本对象进行同步 @local bool 为true则以本地为准,否则以服务端为准
func (*KeyspaceNotification) UnRegistHandler ¶
func (c *KeyspaceNotification) UnRegistHandler(db, key, eventanem string) error
UnRegistHandler 删除特定topic上注册的回调函数 @params topic string 要取消注册回调的topic,注意`*`取消的只是`*`类型的回调并不是全部取消,要全部取消请使用空字符串
type NotificationEvent ¶
type NotificationEvent struct { Type NotificationEventType `json:"type"` DB string `json:"db"` Key string `json:"key"` EventName string `json:"event_name"` }
func (*NotificationEvent) String ¶
func (event *NotificationEvent) String()
type NotificationEventType ¶
type NotificationEventType uint16
NotificationEventType 通知类型
const ( //KeySpaceNotification 键空间通知 KeySpaceNotification NotificationEventType = iota //KeyEventNotification 键事件通知 KeyEventNotification )
type NotificationHanddler ¶
type NotificationHanddler func(evt *NotificationEvent) error
Handdler 处理消息的回调函数 @params msg *NotificationEvent Event对象