Change Publication to Event
This commit is contained in:
		
							
								
								
									
										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 { | ||||
| 	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 { | ||||
| @@ -498,7 +498,7 @@ func (g *grpcClient) Publish(ctx context.Context, p client.Message, opts ...clie | ||||
| 	} | ||||
|  | ||||
| 	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()) | ||||
| 	} | ||||
|  | ||||
|   | ||||
							
								
								
									
										12
									
								
								message.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								message.go
									
									
									
									
									
								
							| @@ -4,13 +4,13 @@ import ( | ||||
| 	"github.com/micro/go-micro/client" | ||||
| ) | ||||
|  | ||||
| type grpcPublication struct { | ||||
| type grpcEvent struct { | ||||
| 	topic       string | ||||
| 	contentType string | ||||
| 	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 | ||||
| 	for _, o := range opts { | ||||
| 		o(&options) | ||||
| @@ -20,21 +20,21 @@ func newGRPCPublication(topic string, payload interface{}, contentType string, o | ||||
| 		contentType = options.ContentType | ||||
| 	} | ||||
|  | ||||
| 	return &grpcPublication{ | ||||
| 	return &grpcEvent{ | ||||
| 		payload:     payload, | ||||
| 		topic:       topic, | ||||
| 		contentType: contentType, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (g *grpcPublication) ContentType() string { | ||||
| func (g *grpcEvent) ContentType() string { | ||||
| 	return g.contentType | ||||
| } | ||||
|  | ||||
| func (g *grpcPublication) Topic() string { | ||||
| func (g *grpcEvent) Topic() string { | ||||
| 	return g.topic | ||||
| } | ||||
|  | ||||
| func (g *grpcPublication) Payload() interface{} { | ||||
| func (g *grpcEvent) Payload() interface{} { | ||||
| 	return g.payload | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user