gitee.com/liuxuezhan/go-micro-v1.18.0@v1.0.0/client/grpc/message.go (about) 1 package grpc 2 3 import ( 4 "gitee.com/liuxuezhan/go-micro-v1.18.0/client" 5 ) 6 7 type grpcEvent struct { 8 topic string 9 contentType string 10 payload interface{} 11 } 12 13 func newGRPCEvent(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message { 14 var options client.MessageOptions 15 for _, o := range opts { 16 o(&options) 17 } 18 19 if len(options.ContentType) > 0 { 20 contentType = options.ContentType 21 } 22 23 return &grpcEvent{ 24 payload: payload, 25 topic: topic, 26 contentType: contentType, 27 } 28 } 29 30 func (g *grpcEvent) ContentType() string { 31 return g.contentType 32 } 33 34 func (g *grpcEvent) Topic() string { 35 return g.topic 36 } 37 38 func (g *grpcEvent) Payload() interface{} { 39 return g.payload 40 }