2019-06-03 20:44:43 +03:00
|
|
|
package grpc
|
|
|
|
|
|
|
|
import (
|
2021-10-27 00:57:12 +03:00
|
|
|
"go.unistack.org/micro/v3/client"
|
2021-12-16 15:34:28 +03:00
|
|
|
"go.unistack.org/micro/v3/metadata"
|
2019-06-03 20:44:43 +03:00
|
|
|
)
|
|
|
|
|
2019-07-07 14:44:09 +03:00
|
|
|
type grpcEvent struct {
|
2021-04-26 19:17:29 +03:00
|
|
|
payload interface{}
|
2019-06-03 20:44:43 +03:00
|
|
|
topic string
|
|
|
|
contentType string
|
2021-12-16 15:34:28 +03:00
|
|
|
opts client.MessageOptions
|
2019-06-03 20:44:43 +03:00
|
|
|
}
|
|
|
|
|
2019-07-07 14:44:09 +03:00
|
|
|
func newGRPCEvent(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message {
|
2021-12-16 15:34:28 +03:00
|
|
|
options := client.NewMessageOptions(opts...)
|
2019-06-03 20:44:43 +03:00
|
|
|
|
|
|
|
if len(options.ContentType) > 0 {
|
|
|
|
contentType = options.ContentType
|
|
|
|
}
|
|
|
|
|
2019-07-07 14:44:09 +03:00
|
|
|
return &grpcEvent{
|
2019-06-03 20:44:43 +03:00
|
|
|
payload: payload,
|
|
|
|
topic: topic,
|
|
|
|
contentType: contentType,
|
2021-12-16 15:34:28 +03:00
|
|
|
opts: options,
|
2019-06-03 20:44:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-07 14:44:09 +03:00
|
|
|
func (g *grpcEvent) ContentType() string {
|
2019-06-03 20:44:43 +03:00
|
|
|
return g.contentType
|
|
|
|
}
|
|
|
|
|
2019-07-07 14:44:09 +03:00
|
|
|
func (g *grpcEvent) Topic() string {
|
2019-06-03 20:44:43 +03:00
|
|
|
return g.topic
|
|
|
|
}
|
|
|
|
|
2019-07-07 14:44:09 +03:00
|
|
|
func (g *grpcEvent) Payload() interface{} {
|
2019-06-03 20:44:43 +03:00
|
|
|
return g.payload
|
|
|
|
}
|
2021-12-16 15:34:28 +03:00
|
|
|
|
|
|
|
func (g *grpcEvent) Metadata() metadata.Metadata {
|
|
|
|
return g.opts.Metadata
|
|
|
|
}
|