Change Publication to Event
This commit is contained in:
parent
9235dfb2a2
commit
1b9e535220
4
grpc.go
4
grpc.go
@ -295,7 +295,7 @@ func (g *grpcClient) Options() client.Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *grpcClient) NewMessage(topic string, msg interface{}, opts ...client.MessageOption) client.Message {
|
func (g *grpcClient) NewMessage(topic string, msg interface{}, opts ...client.MessageOption) client.Message {
|
||||||
return newGRPCPublication(topic, msg, g.opts.ContentType, opts...)
|
return newGRPCEvent(topic, msg, g.opts.ContentType, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *grpcClient) NewRequest(service, method string, req interface{}, reqOpts ...client.RequestOption) client.Request {
|
func (g *grpcClient) NewRequest(service, method string, req interface{}, reqOpts ...client.RequestOption) client.Request {
|
||||||
@ -498,7 +498,7 @@ func (g *grpcClient) Publish(ctx context.Context, p client.Message, opts ...clie
|
|||||||
}
|
}
|
||||||
|
|
||||||
b := &buffer{bytes.NewBuffer(nil)}
|
b := &buffer{bytes.NewBuffer(nil)}
|
||||||
if err := cf(b).Write(&codec.Message{Type: codec.Publication}, p.Payload()); err != nil {
|
if err := cf(b).Write(&codec.Message{Type: codec.Event}, p.Payload()); err != nil {
|
||||||
return errors.InternalServerError("go.micro.client", err.Error())
|
return errors.InternalServerError("go.micro.client", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
message.go
12
message.go
@ -4,13 +4,13 @@ import (
|
|||||||
"github.com/micro/go-micro/client"
|
"github.com/micro/go-micro/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
type grpcPublication struct {
|
type grpcEvent struct {
|
||||||
topic string
|
topic string
|
||||||
contentType string
|
contentType string
|
||||||
payload interface{}
|
payload interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newGRPCPublication(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message {
|
func newGRPCEvent(topic string, payload interface{}, contentType string, opts ...client.MessageOption) client.Message {
|
||||||
var options client.MessageOptions
|
var options client.MessageOptions
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&options)
|
o(&options)
|
||||||
@ -20,21 +20,21 @@ func newGRPCPublication(topic string, payload interface{}, contentType string, o
|
|||||||
contentType = options.ContentType
|
contentType = options.ContentType
|
||||||
}
|
}
|
||||||
|
|
||||||
return &grpcPublication{
|
return &grpcEvent{
|
||||||
payload: payload,
|
payload: payload,
|
||||||
topic: topic,
|
topic: topic,
|
||||||
contentType: contentType,
|
contentType: contentType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *grpcPublication) ContentType() string {
|
func (g *grpcEvent) ContentType() string {
|
||||||
return g.contentType
|
return g.contentType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *grpcPublication) Topic() string {
|
func (g *grpcEvent) Topic() string {
|
||||||
return g.topic
|
return g.topic
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *grpcPublication) Payload() interface{} {
|
func (g *grpcEvent) Payload() interface{} {
|
||||||
return g.payload
|
return g.payload
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user