Documentation
¶
Index ¶
- Constants
- Variables
- type IPub
- type IStatus
- type ISub
- type ISubA
- type ISubPub
- type ISubRA
- type IUnsub
- type PubHub
- type PubSessionIntf
- type SubFunc
- type SubHub
- func (this *SubHub) AddSession(sessionid string, conf gobase.StrMap, fn SubFunc) error
- func (this *SubHub) ConfigDefaultConnType(s string)
- func (this *SubHub) DelSession(sessionid string) bool
- func (this *SubHub) PostData(sessionid string, args ...interface{}) error
- func (this *SubHub) Status() string
- type SubSessionIntf
- type Subchannel
- func (this *Subchannel) CleanChannels() (cnt int)
- func (this *Subchannel) Close() error
- func (this *Subchannel) ClosePubChannel(channel string) (closed bool)
- func (this *Subchannel) GetChannelCount() int
- func (this *Subchannel) GetChannelSessionCount(channel string) int
- func (this *Subchannel) Pub(channel string, max int, args ...interface{}) int
- func (this *Subchannel) Status() string
- func (this *Subchannel) Sub(id, channel string, cb SubFunc)
- func (this *Subchannel) SubR(id, channel string, cb SubFunc) int
- func (this *Subchannel) Unsub(id, channel string) bool
- func (this *Subchannel) UnsubR(id, channel string) (r int)
- type Subscribe
- func (this *Subscribe) CleanChannels() (cnt int)
- func (this *Subscribe) Close() error
- func (this *Subscribe) ClosePubChannel(channel string) (closed bool)
- func (this *Subscribe) Count() int
- func (this *Subscribe) GetTopicSubCount(topic string) int
- func (this *Subscribe) Pub(channel string, max int, args ...interface{}) int
- func (this *Subscribe) Status() string
- func (this *Subscribe) StatusDetail() string
- func (this *Subscribe) Sub(id, topic string, cb SubFunc)
- func (this *Subscribe) SubR(id, topic string, cb SubFunc) (r int)
- func (this *Subscribe) TopicCount() int
- func (this *Subscribe) Unsub(id, topic string) bool
- func (this *Subscribe) UnsubR(id, topic string) (r int)
Constants ¶
View Source
const ( // action, &isOk, confMap ACTION_BEFORE_CONNECT = 1 // actioin[,fromaddr[,data]] ACTION_CONNECTED = 2 // action, buf ACTION_RECVBUF = 3 // action, buf ACTION_SEND_BUF = 4 // action, reason ACTION_DISCONNECTED = 5 // ACTION, msg ACTION_START = 8 // action, msg ACTION_CLOSE = 9 // action, err ACTION_CONNECTFAIL = 10 // action, topic, data ACTION_RECV_TOPIC_DATA = 11 // action, err ACTION_ERROR = 21 ACTION_MESSAGE = 20 // action, string ACTION_SUCCESSFUL = 22 ACTION_CUSTOM = 200 ACTION_SERVER_BASE = 30 // action, sessionid, fromaddr[,data] ACTION_SERVER_CONN_CONNECTED = ACTION_SERVER_BASE + 1 // action, sessionid, buf ACTION_SERVER_CONN_SEND_BUF = ACTION_SERVER_BASE + 2 // action, sessionid, buf ACTION_SERVER_CONN_RECV_BUF = ACTION_SERVER_BASE + 3 // action, sessionid, reason ACTION_SERVER_CONN_DISCONNECTED = ACTION_SERVER_BASE + 4 )
Variables ¶
View Source
var (
DefaultPub = NewPubHub()
)
View Source
var (
DefaultSub = NewSubHub()
)
View Source
var (
DefaultSubchannel = NewSubchannel()
)
View Source
var (
DefaultSubscribe = NewSubscribe()
)
Functions ¶
This section is empty.
Types ¶
type PubHub ¶
type PubHub struct {
// contains filtered or unexported fields
}
发布中心 负责创建管理会话对象 注册的方法必须是pub.开头
func (*PubHub) AddSession ¶
func (this *PubHub) AddSession(sessionid string, conf gobase.StrMap, notifyFn SubFunc) (pub PubSessionIntf, err error)
使用conntype参数, 调用pub.[xxx]注册的方法, 创建一个Pub会话对象
false: 如果sessionid已经存在; conntype参数未注册
type PubSessionIntf ¶
type PubSessionIntf interface { Start() Close() error // 发布数据 Pub(topic string, max int, args ...interface{}) int }
创建的Session对象必须要实现的接口方法
type SubHub ¶
type SubHub struct {
// contains filtered or unexported fields
}
订阅中心 负责创建管理会话对象 注册的方法必须是sub.开头
func (*SubHub) AddSession ¶
func (*SubHub) ConfigDefaultConnType ¶ added in v1.2.24013
func (*SubHub) DelSession ¶
type SubSessionIntf ¶
type Subchannel ¶ added in v1.2.24013
type Subchannel struct {
// contains filtered or unexported fields
}
订阅中心, 订阅和取消订阅的效率比subscribe快很多 订阅主题 Sub消息通道不支持通配符
func NewSubchannel ¶ added in v1.2.24013
func NewSubchannel() *Subchannel
func (*Subchannel) CleanChannels ¶ added in v1.2.24013
func (this *Subchannel) CleanChannels() (cnt int)
清理一些超时10分钟没有发布消息的通道
func (*Subchannel) Close ¶ added in v1.2.24013
func (this *Subchannel) Close() error
func (*Subchannel) ClosePubChannel ¶ added in v1.2.24013
func (this *Subchannel) ClosePubChannel(channel string) (closed bool)
释放通道
func (*Subchannel) GetChannelCount ¶ added in v1.2.24013
func (this *Subchannel) GetChannelCount() int
func (*Subchannel) GetChannelSessionCount ¶ added in v1.2.24013
func (this *Subchannel) GetChannelSessionCount(channel string) int
func (*Subchannel) Pub ¶ added in v1.2.24013
func (this *Subchannel) Pub(channel string, max int, args ...interface{}) int
0:发布数据失败
func (*Subchannel) Status ¶ added in v1.2.24013
func (this *Subchannel) Status() string
func (*Subchannel) Sub ¶ added in v1.2.24013
func (this *Subchannel) Sub(id, channel string, cb SubFunc)
channel不能为空
func (*Subchannel) SubR ¶
func (this *Subchannel) SubR(id, channel string, cb SubFunc) int
id/channel can't be empty
func (*Subchannel) Unsub ¶ added in v1.2.24013
func (this *Subchannel) Unsub(id, channel string) bool
func (*Subchannel) UnsubR ¶
func (this *Subchannel) UnsubR(id, channel string) (r int)
id/channel can't be empty r: -1 channel 不存在, >=0 channel 订阅数量
type Subscribe ¶ added in v1.2.24013
type Subscribe struct {
// contains filtered or unexported fields
}
订阅中心, 订阅主题:支持通配符/news/+/qq, 将会收到匹配的的通道消息 PUB消息通道不支持通配符
func NewSubscribe ¶ added in v1.2.24013
func NewSubscribe() *Subscribe
func NewSubscribeEx ¶ added in v1.2.24013
func (*Subscribe) CleanChannels ¶ added in v1.2.24013
清理一些超时10分钟没有发布消息的通道
func (*Subscribe) ClosePubChannel ¶ added in v1.2.24013
释放通道
func (*Subscribe) GetTopicSubCount ¶ added in v1.2.24013
func (*Subscribe) Pub ¶ added in v1.2.24013
>1 投递成功max次后停止 循环map
utils_subscribe_v2._test.go:168: 34228, 6844/s utils_subscribe_v2._test.go:168: 68952, 6894/s
循环lst
utils_subscribe_v2._test.go:168: 35343, 6977/s utils_subscribe_v2._test.go:168: 71194, 7072/s
向主题订阅者推送数据 topic推送的主题 max最大接收者,超过该值不再进行推送
func (*Subscribe) StatusDetail ¶ added in v1.2.24013
func (*Subscribe) Sub ¶ added in v1.2.24013
订阅一个主题
topic订阅主题,为空不进行订阅 id订阅者id,topic 下id重复将会被覆盖(之前订阅失效)
func (*Subscribe) TopicCount ¶ added in v1.2.24013
Click to show internal directories.
Click to hide internal directories.