From 609a59d3ab7bac45eeed0b2dfd30434872c89215 Mon Sep 17 00:00:00 2001 From: Asim Date: Sat, 28 Nov 2015 16:39:25 +0000 Subject: [PATCH] add local envelope --- codec/proto/envelope.pb.go | 83 ++++++++++++++++++++++++++++++++++++++ codec/proto/envelope.proto | 12 ++++++ codec/proto/proto.go | 9 ++--- 3 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 codec/proto/envelope.pb.go create mode 100644 codec/proto/envelope.proto diff --git a/codec/proto/envelope.pb.go b/codec/proto/envelope.pb.go new file mode 100644 index 00000000..426ed6a1 --- /dev/null +++ b/codec/proto/envelope.pb.go @@ -0,0 +1,83 @@ +// Code generated by protoc-gen-go. +// source: envelope.proto +// DO NOT EDIT! + +/* +Package proto is a generated protocol buffer package. + +It is generated from these files: + envelope.proto + +It has these top-level messages: + Request + Response +*/ +package proto + +import proto "github.com/golang/protobuf/proto" +import json "encoding/json" +import math "math" + +// Reference proto, json, and math imports to suppress error if they are not otherwise used. +var _ = proto.Marshal +var _ = &json.SyntaxError{} +var _ = math.Inf + +type Request struct { + ServiceMethod *string `protobuf:"bytes,1,opt,name=service_method" json:"service_method,omitempty"` + Seq *uint64 `protobuf:"fixed64,2,opt,name=seq" json:"seq,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Request) Reset() { *m = Request{} } +func (m *Request) String() string { return proto.CompactTextString(m) } +func (*Request) ProtoMessage() {} + +func (m *Request) GetServiceMethod() string { + if m != nil && m.ServiceMethod != nil { + return *m.ServiceMethod + } + return "" +} + +func (m *Request) GetSeq() uint64 { + if m != nil && m.Seq != nil { + return *m.Seq + } + return 0 +} + +type Response struct { + ServiceMethod *string `protobuf:"bytes,1,opt,name=service_method" json:"service_method,omitempty"` + Seq *uint64 `protobuf:"fixed64,2,opt,name=seq" json:"seq,omitempty"` + Error *string `protobuf:"bytes,3,opt,name=error" json:"error,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Response) Reset() { *m = Response{} } +func (m *Response) String() string { return proto.CompactTextString(m) } +func (*Response) ProtoMessage() {} + +func (m *Response) GetServiceMethod() string { + if m != nil && m.ServiceMethod != nil { + return *m.ServiceMethod + } + return "" +} + +func (m *Response) GetSeq() uint64 { + if m != nil && m.Seq != nil { + return *m.Seq + } + return 0 +} + +func (m *Response) GetError() string { + if m != nil && m.Error != nil { + return *m.Error + } + return "" +} + +func init() { +} diff --git a/codec/proto/envelope.proto b/codec/proto/envelope.proto new file mode 100644 index 00000000..630714ca --- /dev/null +++ b/codec/proto/envelope.proto @@ -0,0 +1,12 @@ +package proto; + +message Request { + optional string service_method = 1; + optional fixed64 seq = 2; +} + +message Response { + optional string service_method = 1; + optional fixed64 seq = 2; + optional string error = 3; +} diff --git a/codec/proto/proto.go b/codec/proto/proto.go index f24126f2..4cd933c2 100644 --- a/codec/proto/proto.go +++ b/codec/proto/proto.go @@ -8,7 +8,6 @@ import ( "github.com/golang/protobuf/proto" "github.com/micro/go-micro/codec" - rpc "github.com/youtube/vitess/go/rpcplus/pbrpc" ) type flusher interface { @@ -37,7 +36,7 @@ func (c *protoCodec) Write(m *codec.Message, b interface{}) error { c.Lock() defer c.Unlock() // This is protobuf, of course we copy it. - pbr := &rpc.Request{ServiceMethod: &m.Method, Seq: &m.Id} + pbr := &Request{ServiceMethod: &m.Method, Seq: &m.Id} data, err := proto.Marshal(pbr) if err != nil { return err @@ -61,7 +60,7 @@ func (c *protoCodec) Write(m *codec.Message, b interface{}) error { case codec.Response: c.Lock() defer c.Unlock() - rtmp := &rpc.Response{ServiceMethod: &m.Method, Seq: &m.Id, Error: &m.Error} + rtmp := &Response{ServiceMethod: &m.Method, Seq: &m.Id, Error: &m.Error} data, err := proto.Marshal(rtmp) if err != nil { return err @@ -107,7 +106,7 @@ func (c *protoCodec) ReadHeader(m *codec.Message, mt codec.MessageType) error { if err != nil { return err } - rtmp := new(rpc.Request) + rtmp := new(Request) err = proto.Unmarshal(data, rtmp) if err != nil { return err @@ -119,7 +118,7 @@ func (c *protoCodec) ReadHeader(m *codec.Message, mt codec.MessageType) error { if err != nil { return err } - rtmp := new(rpc.Response) + rtmp := new(Response) err = proto.Unmarshal(data, rtmp) if err != nil { return err