2020-07-27 15:22:00 +03:00
|
|
|
package mucp
|
|
|
|
|
|
|
|
import (
|
2020-08-19 17:47:17 +03:00
|
|
|
"github.com/unistack-org/micro/v3/client"
|
2020-07-27 15:22:00 +03:00
|
|
|
)
|
2018-04-14 20:06:52 +03:00
|
|
|
|
|
|
|
type message struct {
|
|
|
|
topic string
|
|
|
|
contentType string
|
|
|
|
payload interface{}
|
|
|
|
}
|
|
|
|
|
2020-07-27 15:22:00 +03:00
|
|
|
func newMessage(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message {
|
|
|
|
var options client.MessageOptions
|
2018-05-10 19:33:54 +03:00
|
|
|
for _, o := range opts {
|
|
|
|
o(&options)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(options.ContentType) > 0 {
|
|
|
|
contentType = options.ContentType
|
|
|
|
}
|
|
|
|
|
2018-04-14 20:06:52 +03:00
|
|
|
return &message{
|
|
|
|
payload: payload,
|
|
|
|
topic: topic,
|
|
|
|
contentType: contentType,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *message) ContentType() string {
|
|
|
|
return m.contentType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *message) Topic() string {
|
|
|
|
return m.topic
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *message) Payload() interface{} {
|
|
|
|
return m.payload
|
|
|
|
}
|