github.com/zly-app/zapp@v1.3.3/core/component.msgbus.go (about) 1 /* 2 ------------------------------------------------- 3 Author : zlyuancn 4 date: 2021/3/19 5 Description : 6 ------------------------------------------------- 7 */ 8 9 package core 10 11 // 消息总线 12 type IMsgbus interface { 13 // 发布 14 Publish(topic string, msg interface{}) 15 // 订阅, 返回订阅号 16 Subscribe(topic string, threadCount int, handler MsgbusHandler) (subscribeId uint32) 17 // 全局订阅, 会收到所有消息 18 SubscribeGlobal(threadCount int, handler MsgbusHandler) (subscribeId uint32) 19 // 取消订阅 20 Unsubscribe(topic string, subscribeId uint32) 21 // 取消全局订阅 22 UnsubscribeGlobal(subscribeId uint32) 23 // 关闭主题, 同时关闭所有订阅该主题的订阅者 24 CloseTopic(topic string) 25 // 关闭 26 Close() 27 } 28 29 type IMsgbusContext interface { 30 ILogger 31 Topic() string 32 Msg() interface{} 33 } 34 35 // 处理函数 36 type MsgbusHandler = func(ctx IMsgbusContext) error