Documentation
¶
Index ¶
- Variables
- type CloseListenerFunc
- type PubSubManager
- func (psm *PubSubManager) AddChannel(channelid string)
- func (psm *PubSubManager) ChannelInUse(channelid string) bool
- func (psm *PubSubManager) Channels() []string
- func (psm *PubSubManager) CloseChannel(channelid string)
- func (psm *PubSubManager) CloseNotify(channelid string) (ch <-chan struct{}, ok bool)
- func (psm *PubSubManager) Publish(msg interface{}, channels ...string)
- func (psm *PubSubManager) PublishWithDefault(msg interface{}, channels ...string)
- func (psm *PubSubManager) RegistListener(channelid string, size int) (<-chan interface{}, <-chan struct{}, CloseListenerFunc, error)
Constants ¶
This section is empty.
Variables ¶
var PubSub = NewPubSubManager()
Functions ¶
This section is empty.
Types ¶
type CloseListenerFunc ¶
type CloseListenerFunc func()
type PubSubManager ¶
type PubSubManager struct {
// contains filtered or unexported fields
}
PubSubManager 广播器
func (*PubSubManager) AddChannel ¶
func (psm *PubSubManager) AddChannel(channelid string)
AddChannel 将频道注册到系统中允许监听
func (*PubSubManager) ChannelInUse ¶
func (psm *PubSubManager) ChannelInUse(channelid string) bool
ChannelInUse 检测channeldid是否在被使用
func (*PubSubManager) Channels ¶
func (psm *PubSubManager) Channels() []string
Channels 查看现在被注册的频道有哪些
func (*PubSubManager) CloseChannel ¶
func (psm *PubSubManager) CloseChannel(channelid string)
CloseChannel 关闭频道操作.会将频道id先去除不再允许注册监听器,然后将频道id下的所有监听器去除
func (*PubSubManager) CloseNotify ¶
func (psm *PubSubManager) CloseNotify(channelid string) (ch <-chan struct{}, ok bool)
CloseNotify 关闭指定频道的信号提醒 @Param channelid string 频道id @Returns <-chan struct{} 关闭频道所有监听器的信号channel @Returns bool 当前频道是否可用
func (*PubSubManager) Publish ¶
func (psm *PubSubManager) Publish(msg interface{}, channels ...string)
Publish 指定频道广播消息 @Param msg interface{} 广播的消息 @Param channels ...string 广播的频道
func (*PubSubManager) PublishWithDefault ¶
func (psm *PubSubManager) PublishWithDefault(msg interface{}, channels ...string)
PublishWithDefault 指定频道广播消息,消息一并广播到default这个channel上 @Param msg interface{} 广播的消息 @Param channels ...string 广播的频道
func (*PubSubManager) RegistListener ¶
func (psm *PubSubManager) RegistListener(channelid string, size int) (<-chan interface{}, <-chan struct{}, CloseListenerFunc, error)
RegistListener 注册频道的监听器 @Param channelid string 频道id @Param size int 构造的消息channel的缓冲区大小,<=0时使用无缓冲channel @Returns <-chan interface{} 消息channel @Returns <-chan struct{} 关闭监听器的信号channel @Returns CloseListenerFunc 关闭当前注册监听器的函数 @Returns error 当频道未被注册可以使用时会报错