mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-18 08:26:38 +02:00
37 lines
637 B
Go
37 lines
637 B
Go
package client
|
|
|
|
type message struct {
|
|
payload interface{}
|
|
topic string
|
|
contentType string
|
|
}
|
|
|
|
func newMessage(topic string, payload interface{}, contentType string, opts ...MessageOption) Message {
|
|
var options MessageOptions
|
|
for _, o := range opts {
|
|
o(&options)
|
|
}
|
|
|
|
if len(options.ContentType) > 0 {
|
|
contentType = options.ContentType
|
|
}
|
|
|
|
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
|
|
}
|