Documentation
¶
Overview ¶
package Eventbus is an enhanced version of the standalone pub-sub asynchronous messaging framework. The system provides a large throughput of stand-alone message engine frameworks. In addition to the general news subscription, the release of the functional support, but also can be used for server-side ECS application scenarios. Has the following features: 1. Large throughput, 1000wQPS 2. Topic [filter] support 3. Statistics plug-in support
Package eventbus is a simple subscription service module that provides asynchronous message distribution based on single computer memory
Index ¶
- Variables
- type Bus
- func (bus *Bus) InitTopic(topicName string, statics Statistics) error
- func (bus *Bus) LoadFilter(topic string, filter Filter) error
- func (bus *Bus) Push(topicName string, message interface{}) error
- func (bus *Bus) Statistic(names ...string) []Statistics
- func (bus *Bus) Stop()
- func (bus *Bus) StopGracefull()
- func (bus *Bus) Subscribe(handle CallFunc, topicNames ...string) (Subscribe, error)
- func (bus *Bus) UnloadFilter(topic string, filter Filter) error
- type CallFunc
- type Filter
- type Statistics
- type Subscribe
- type Topic
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus is a subscription service module
func (*Bus) InitTopic ¶
func (bus *Bus) InitTopic(topicName string, statics Statistics) error
InitTopic use this method to set statics before Subscribe if we need to set
func (*Bus) Statistic ¶
func (bus *Bus) Statistic(names ...string) []Statistics
func (*Bus) Stop ¶
func (bus *Bus) Stop()
Stop immediately stop the execution of eventbus ,dropping all unreceived msg in topic mailbox
func (*Bus) StopGracefull ¶
func (bus *Bus) StopGracefull()
StopGracefull block for stoping eventbus until all messages are received by the consumer
type CallFunc ¶
type CallFunc func(message interface{})
CallFunc definition of the consumer function which eventbus call
type Filter ¶
type Filter interface {
//HandleMessage handle message and return it's judge ,
// if one or more Filter return FALSE ,the consumers can not receive it
HandleMessage(message interface{}) (proceed bool)
}
Filter monitor the topic input message .one topic can add many Filter. the Filter will be invoke before the topic send message to consumer.
type Statistics ¶
type Statistics interface {
SetTopicName(topciName string)
TopicSubscribe()
TopicUnscribe()
FilterLoad()
FilterUnload()
MessagePushed(message interface{})
MessageReceived(message interface{})
}
type Topic ¶
type Topic struct {
Name string
// contains filtered or unexported fields
}
Topic 是一个订阅消息的运行对象定义,封装了邮箱和消费者
func NewTopic ¶
func NewTopic(topicName string, statitic Statistics) *Topic
NewTopic topic constructor
func (*Topic) Close ¶
func (topic *Topic) Close()
Close close topic until all messages have been sent to the registered client.
func (*Topic) Info ¶
func (topic *Topic) Info() Statistics
func (*Topic) PostCmdMessage ¶
func (topic *Topic) PostCmdMessage(message interface{})
func (*Topic) PostUserMessage ¶
func (topic *Topic) PostUserMessage(message interface{})
func (*Topic) ReceiveCmdMessage ¶
func (topic *Topic) ReceiveCmdMessage(message interface{})
func (*Topic) ReceiveUserMessage ¶
func (topic *Topic) ReceiveUserMessage(message interface{})