2019-06-03 18:44:43 +01:00
|
|
|
package grpc
|
|
|
|
|
|
|
|
import (
|
2020-09-18 18:27:29 +03:00
|
|
|
"github.com/unistack-org/micro/v3/client"
|
2019-06-03 18:44:43 +01:00
|
|
|
)
|
|
|
|
|
2019-07-07 12:44:09 +01:00
|
|
|
type grpcEvent struct {
|
2021-04-26 19:17:29 +03:00
|
|
|
payload interface{}
|
2019-06-03 18:44:43 +01:00
|
|
|
topic string
|
|
|
|
contentType string
|
|
|
|
}
|
|
|
|
|
2019-07-07 12:44:09 +01:00
|
|
|
func newGRPCEvent(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message {
|
2019-06-03 18:44:43 +01:00
|
|
|
var options client.MessageOptions
|
|
|
|
for _, o := range opts {
|
|
|
|
o(&options)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(options.ContentType) > 0 {
|
|
|
|
contentType = options.ContentType
|
|
|
|
}
|
|
|
|
|
2019-07-07 12:44:09 +01:00
|
|
|
return &grpcEvent{
|
2019-06-03 18:44:43 +01:00
|
|
|
payload: payload,
|
|
|
|
topic: topic,
|
|
|
|
contentType: contentType,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-07 12:44:09 +01:00
|
|
|
func (g *grpcEvent) ContentType() string {
|
2019-06-03 18:44:43 +01:00
|
|
|
return g.contentType
|
|
|
|
}
|
|
|
|
|
2019-07-07 12:44:09 +01:00
|
|
|
func (g *grpcEvent) Topic() string {
|
2019-06-03 18:44:43 +01:00
|
|
|
return g.topic
|
|
|
|
}
|
|
|
|
|
2019-07-07 12:44:09 +01:00
|
|
|
func (g *grpcEvent) Payload() interface{} {
|
2019-06-03 18:44:43 +01:00
|
|
|
return g.payload
|
|
|
|
}
|