github.com/zly-app/zapp@v1.3.3/component/msgbus/context.go (about) 1 package msgbus 2 3 import ( 4 "go.uber.org/zap" 5 6 "github.com/zly-app/zapp/core" 7 "github.com/zly-app/zapp/logger" 8 ) 9 10 const msgbusTopicKey = "msgbus_topic" 11 12 // 通道消息 13 type channelMsg struct { 14 topic string 15 msg interface{} 16 } 17 18 type Context struct { 19 core.ILogger 20 topic string 21 msg interface{} 22 } 23 24 func newContext(msg *channelMsg) core.IMsgbusContext { 25 return &Context{ 26 ILogger: logger.Log.NewSessionLogger(zap.String(msgbusTopicKey, msg.topic)), 27 topic: msg.topic, 28 msg: msg.msg, 29 } 30 } 31 func (c *Context) Topic() string { 32 return c.topic 33 } 34 func (c *Context) Msg() interface{} { 35 return c.msg 36 }