Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerRecord ¶
type HandlerRecord struct {
ID string // 每个订阅都需要分配一个 ID,方便日志查找及取消订阅
Handler dinfra.EventHandler // 事件的处理函数
}
func CopyHandlers ¶
func CopyHandlers(node *Node, records []*HandlerRecord) []*HandlerRecord
func MacthHandlers ¶
func MacthHandlers(node *Node, keys []string) []*HandlerRecord
func RemoveRecord ¶
func RemoveRecord(node *Node, subscribeID string) *HandlerRecord
type MemoryEventBus ¶
type MemoryEventBus struct {
// contains filtered or unexported fields
}
func NewMemoryEventBus ¶
func NewMemoryEventBus( logger dinfra.Logger, ) *MemoryEventBus
func (*MemoryEventBus) Subscribe ¶
func (bus *MemoryEventBus) Subscribe( topic string, handler dinfra.EventHandler, ) (string, error)
func (*MemoryEventBus) Unsubscribe ¶
func (bus *MemoryEventBus) Unsubscribe( subscribeID string, ) error
type Node ¶
type Node struct {
Key string // 节点的订阅字符
Topic string // 对应的主题
Handlers map[string]*HandlerRecord // 对应的 handler 记录
Children map[string]*Node // 子项
}
做成一个简单的树结构,可以处理 + # 等特殊匹配
func BuildeNode ¶
Click to show internal directories.
Click to hide internal directories.