Documentation ¶
Index ¶
- Constants
- func GenSubscriberID() string
- func ListEvents() (events []string)
- func Publish(eventName string, event ...interface{})
- func RegistEvent(eventNames ...string) error
- func Unsubscribe(eventName string, ids ...string) error
- type Bus
- type Center
- func (p *Center) ListEvents() (events []string)
- func (p *Center) Name() string
- func (p *Center) Publish(eventName string, evts ...interface{})
- func (p *Center) RegistEvent(eventNames ...string) error
- func (p *Center) Subscribe(eventName string, fn func(...interface{})) (Subscriber, error)
- func (p *Center) Unsubscribe(eventName string, ids ...string) error
- func (p *Center) UnsubscribeAll(eventName string)
- type GroupOption
- type Subscriber
- type SubscriberGroup
Constants ¶
View Source
const ( // 普通模式 SubscriberModelNormal = iota // 并发模式 SubscriberModelGoutine )
SubscriberModel 消费者模式
View Source
const DefaultEventCenterName = "trellis::event::default-center"
DefaultEventCenterName default event center name
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bus ¶
type Bus interface { RegistEvent(eventNames ...string) error Subscribe(eventName string, fn func(...interface{})) (Subscriber, error) Unsubscribe(eventName string, ids ...string) error UnsubscribeAll(eventName string) Publish(eventName string, evt ...interface{}) ListEvents() (events []string) }
Bus xxx
type Center ¶
type Center struct {
// contains filtered or unexported fields
}
Center xxx
func (*Center) RegistEvent ¶
RegistEvent 注册事件
func (*Center) Subscribe ¶
func (p *Center) Subscribe(eventName string, fn func(...interface{})) (Subscriber, error)
Subscribe 监听
func (*Center) Unsubscribe ¶
Unsubscribe 取消监听
func (*Center) UnsubscribeAll ¶
UnsubscribeAll 取消全部监听
type GroupOption ¶
type GroupOption func(*defSubscriberGroup)
GroupOption 操作配置函数
func GroupSubscriberModel ¶
func GroupSubscriberModel(model int) GroupOption
GroupSubscriberModel 组的分享类型
type Subscriber ¶
type Subscriber interface { GetID() string Publish(values ...interface{}) Stop() }
Subscriber 消费者
func NewDefSubscriber ¶
func NewDefSubscriber(sub interface{}) (Subscriber, error)
NewDefSubscriber 生成默认的消费者
func Subscribe ¶
func Subscribe(eventName string, fn func(...interface{})) (Subscriber, error)
Subscribe 监听
type SubscriberGroup ¶
type SubscriberGroup interface { Subscriber(interface{}) (Subscriber, error) RemoveSubscriber(ids ...string) error Publish(values ...interface{}) ClearSubscribers() }
SubscriberGroup 消费者组
func NewSubscriberGroup ¶
func NewSubscriberGroup(opts ...GroupOption) SubscriberGroup
NewSubscriberGroup xxx
Click to show internal directories.
Click to hide internal directories.