mirror of
https://github.com/go-micro/go-micro.git
synced 2024-12-24 10:07:04 +02:00
41 lines
752 B
Go
41 lines
752 B
Go
|
package grpc
|
||
|
|
||
|
import (
|
||
|
"github.com/micro/go-micro/client"
|
||
|
)
|
||
|
|
||
|
type grpcPublication struct {
|
||
|
topic string
|
||
|
contentType string
|
||
|
payload interface{}
|
||
|
}
|
||
|
|
||
|
func newGRPCPublication(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message {
|
||
|
var options client.MessageOptions
|
||
|
for _, o := range opts {
|
||
|
o(&options)
|
||
|
}
|
||
|
|
||
|
if len(options.ContentType) > 0 {
|
||
|
contentType = options.ContentType
|
||
|
}
|
||
|
|
||
|
return &grpcPublication{
|
||
|
payload: payload,
|
||
|
topic: topic,
|
||
|
contentType: contentType,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (g *grpcPublication) ContentType() string {
|
||
|
return g.contentType
|
||
|
}
|
||
|
|
||
|
func (g *grpcPublication) Topic() string {
|
||
|
return g.topic
|
||
|
}
|
||
|
|
||
|
func (g *grpcPublication) Payload() interface{} {
|
||
|
return g.payload
|
||
|
}
|