升级为protobuf3

This commit is contained in:
boyce
2020-12-10 15:50:42 +08:00
parent 96b983a7cf
commit e2a156473b
3 changed files with 122 additions and 212 deletions

View File

@@ -23,17 +23,17 @@ func init(){
} }
func (slf *PBRpcRequestData) MakeRequest(seq uint64,serviceMethod string,noReply bool,inParam []byte) *PBRpcRequestData{ func (slf *PBRpcRequestData) MakeRequest(seq uint64,serviceMethod string,noReply bool,inParam []byte) *PBRpcRequestData{
slf.Seq = proto.Uint64(seq) slf.Seq = seq
slf.ServiceMethod = proto.String(serviceMethod) slf.ServiceMethod = serviceMethod
slf.NoReply = proto.Bool(noReply) slf.NoReply = noReply
slf.InParam = inParam slf.InParam = inParam
return slf return slf
} }
func (slf *PBRpcResponseData) MakeRespone(seq uint64,err RpcError,reply []byte) *PBRpcResponseData{ func (slf *PBRpcResponseData) MakeRespone(seq uint64,err RpcError,reply []byte) *PBRpcResponseData{
slf.Seq = proto.Uint64(seq) slf.Seq = seq
slf.Error = proto.String(err.Error()) slf.Error = err.Error()
slf.Reply = reply slf.Reply = reply
return slf return slf

View File

@@ -1,253 +1,163 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // source: rpcproto/rpc.proto
// protoc-gen-go v1.23.0
// protoc (unknown)
// source: rpc.proto
package rpc package rpc
import ( import (
fmt "fmt"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" math "math"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
) )
const ( // Reference imports to suppress errors if they are not otherwise used.
// Verify that this generated code is sufficiently up-to-date. var _ = proto.Marshal
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) var _ = fmt.Errorf
// Verify that runtime/protoimpl is sufficiently up-to-date. var _ = math.Inf
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version // This is a compile-time assertion to ensure that this generated file
// of the legacy proto package is being used. // is compatible with the proto package it is being compiled against.
const _ = proto.ProtoPackageIsVersion4 // A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type PBRpcRequestData struct { type PBRpcRequestData struct {
state protoimpl.MessageState Seq uint64 `protobuf:"varint,1,opt,name=Seq,proto3" json:"Seq,omitempty"`
sizeCache protoimpl.SizeCache ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"`
unknownFields protoimpl.UnknownFields NoReply bool `protobuf:"varint,3,opt,name=NoReply,proto3" json:"NoReply,omitempty"`
InParam []byte `protobuf:"bytes,4,opt,name=InParam,proto3" json:"InParam,omitempty"`
Seq *uint64 `protobuf:"varint,1,opt,name=Seq" json:"Seq,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
ServiceMethod *string `protobuf:"bytes,2,opt,name=ServiceMethod" json:"ServiceMethod,omitempty"` XXX_unrecognized []byte `json:"-"`
NoReply *bool `protobuf:"varint,3,opt,name=NoReply" json:"NoReply,omitempty"` XXX_sizecache int32 `json:"-"`
InParam []byte `protobuf:"bytes,4,opt,name=InParam" json:"InParam,omitempty"`
} }
func (x *PBRpcRequestData) Reset() { func (m *PBRpcRequestData) Reset() { *m = PBRpcRequestData{} }
*x = PBRpcRequestData{} func (m *PBRpcRequestData) String() string { return proto.CompactTextString(m) }
if protoimpl.UnsafeEnabled { func (*PBRpcRequestData) ProtoMessage() {}
mi := &file_rpc_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PBRpcRequestData) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PBRpcRequestData) ProtoMessage() {}
func (x *PBRpcRequestData) ProtoReflect() protoreflect.Message {
mi := &file_rpc_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PBRpcRequestData.ProtoReflect.Descriptor instead.
func (*PBRpcRequestData) Descriptor() ([]byte, []int) { func (*PBRpcRequestData) Descriptor() ([]byte, []int) {
return file_rpc_proto_rawDescGZIP(), []int{0} return fileDescriptor_0008ed1de5480352, []int{0}
} }
func (x *PBRpcRequestData) GetSeq() uint64 { func (m *PBRpcRequestData) XXX_Unmarshal(b []byte) error {
if x != nil && x.Seq != nil { return xxx_messageInfo_PBRpcRequestData.Unmarshal(m, b)
return *x.Seq }
func (m *PBRpcRequestData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PBRpcRequestData.Marshal(b, m, deterministic)
}
func (m *PBRpcRequestData) XXX_Merge(src proto.Message) {
xxx_messageInfo_PBRpcRequestData.Merge(m, src)
}
func (m *PBRpcRequestData) XXX_Size() int {
return xxx_messageInfo_PBRpcRequestData.Size(m)
}
func (m *PBRpcRequestData) XXX_DiscardUnknown() {
xxx_messageInfo_PBRpcRequestData.DiscardUnknown(m)
}
var xxx_messageInfo_PBRpcRequestData proto.InternalMessageInfo
func (m *PBRpcRequestData) GetSeq() uint64 {
if m != nil {
return m.Seq
} }
return 0 return 0
} }
func (x *PBRpcRequestData) GetServiceMethod() string { func (m *PBRpcRequestData) GetServiceMethod() string {
if x != nil && x.ServiceMethod != nil { if m != nil {
return *x.ServiceMethod return m.ServiceMethod
} }
return "" return ""
} }
func (x *PBRpcRequestData) GetNoReply() bool { func (m *PBRpcRequestData) GetNoReply() bool {
if x != nil && x.NoReply != nil { if m != nil {
return *x.NoReply return m.NoReply
} }
return false return false
} }
func (x *PBRpcRequestData) GetInParam() []byte { func (m *PBRpcRequestData) GetInParam() []byte {
if x != nil { if m != nil {
return x.InParam return m.InParam
} }
return nil return nil
} }
type PBRpcResponseData struct { type PBRpcResponseData struct {
state protoimpl.MessageState Seq uint64 `protobuf:"varint,1,opt,name=Seq,proto3" json:"Seq,omitempty"`
sizeCache protoimpl.SizeCache Error string `protobuf:"bytes,2,opt,name=Error,proto3" json:"Error,omitempty"`
unknownFields protoimpl.UnknownFields Reply []byte `protobuf:"bytes,3,opt,name=Reply,proto3" json:"Reply,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
Seq *uint64 `protobuf:"varint,1,opt,name=Seq" json:"Seq,omitempty"` XXX_unrecognized []byte `json:"-"`
Error *string `protobuf:"bytes,2,opt,name=Error" json:"Error,omitempty"` XXX_sizecache int32 `json:"-"`
Reply []byte `protobuf:"bytes,3,opt,name=Reply" json:"Reply,omitempty"`
} }
func (x *PBRpcResponseData) Reset() { func (m *PBRpcResponseData) Reset() { *m = PBRpcResponseData{} }
*x = PBRpcResponseData{} func (m *PBRpcResponseData) String() string { return proto.CompactTextString(m) }
if protoimpl.UnsafeEnabled { func (*PBRpcResponseData) ProtoMessage() {}
mi := &file_rpc_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PBRpcResponseData) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PBRpcResponseData) ProtoMessage() {}
func (x *PBRpcResponseData) ProtoReflect() protoreflect.Message {
mi := &file_rpc_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PBRpcResponseData.ProtoReflect.Descriptor instead.
func (*PBRpcResponseData) Descriptor() ([]byte, []int) { func (*PBRpcResponseData) Descriptor() ([]byte, []int) {
return file_rpc_proto_rawDescGZIP(), []int{1} return fileDescriptor_0008ed1de5480352, []int{1}
} }
func (x *PBRpcResponseData) GetSeq() uint64 { func (m *PBRpcResponseData) XXX_Unmarshal(b []byte) error {
if x != nil && x.Seq != nil { return xxx_messageInfo_PBRpcResponseData.Unmarshal(m, b)
return *x.Seq }
func (m *PBRpcResponseData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PBRpcResponseData.Marshal(b, m, deterministic)
}
func (m *PBRpcResponseData) XXX_Merge(src proto.Message) {
xxx_messageInfo_PBRpcResponseData.Merge(m, src)
}
func (m *PBRpcResponseData) XXX_Size() int {
return xxx_messageInfo_PBRpcResponseData.Size(m)
}
func (m *PBRpcResponseData) XXX_DiscardUnknown() {
xxx_messageInfo_PBRpcResponseData.DiscardUnknown(m)
}
var xxx_messageInfo_PBRpcResponseData proto.InternalMessageInfo
func (m *PBRpcResponseData) GetSeq() uint64 {
if m != nil {
return m.Seq
} }
return 0 return 0
} }
func (x *PBRpcResponseData) GetError() string { func (m *PBRpcResponseData) GetError() string {
if x != nil && x.Error != nil { if m != nil {
return *x.Error return m.Error
} }
return "" return ""
} }
func (x *PBRpcResponseData) GetReply() []byte { func (m *PBRpcResponseData) GetReply() []byte {
if x != nil { if m != nil {
return x.Reply return m.Reply
} }
return nil return nil
} }
var File_rpc_proto protoreflect.FileDescriptor func init() {
proto.RegisterType((*PBRpcRequestData)(nil), "rpc.PBRpcRequestData")
var file_rpc_proto_rawDesc = []byte{ proto.RegisterType((*PBRpcResponseData)(nil), "rpc.PBRpcResponseData")
0x0a, 0x09, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x72, 0x70, 0x63,
0x22, 0x58, 0x0a, 0x10, 0x50, 0x42, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x44, 0x61, 0x74, 0x61, 0x12, 0x0b, 0x0a, 0x03, 0x53, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28,
0x04, 0x12, 0x15, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68,
0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x12, 0x0f, 0x0a, 0x07, 0x4e, 0x6f, 0x52, 0x65,
0x70, 0x6c, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x12, 0x0f, 0x0a, 0x07, 0x49, 0x6e, 0x50,
0x61, 0x72, 0x61, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x22, 0x3e, 0x0a, 0x11, 0x50, 0x42,
0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12,
0x0b, 0x0a, 0x03, 0x53, 0x65, 0x71, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x12, 0x0d, 0x0a, 0x05,
0x45, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x12, 0x0d, 0x0a, 0x05, 0x52,
0x65, 0x70, 0x6c, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x3b,
0x72, 0x70, 0x63,
} }
var ( func init() { proto.RegisterFile("rpcproto/rpc.proto", fileDescriptor_0008ed1de5480352) }
file_rpc_proto_rawDescOnce sync.Once
file_rpc_proto_rawDescData = file_rpc_proto_rawDesc
)
func file_rpc_proto_rawDescGZIP() []byte { var fileDescriptor_0008ed1de5480352 = []byte{
file_rpc_proto_rawDescOnce.Do(func() { // 193 bytes of a gzipped FileDescriptorProto
file_rpc_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_proto_rawDescData) 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2a, 0x2a, 0x48, 0x2e,
}) 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x2f, 0x2a, 0x48, 0xd6, 0x03, 0xb3, 0x84, 0x98, 0x8b, 0x0a, 0x92,
return file_rpc_proto_rawDescData 0x95, 0xea, 0xb8, 0x04, 0x02, 0x9c, 0x82, 0x0a, 0x92, 0x83, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b,
} 0x5c, 0x12, 0x4b, 0x12, 0x85, 0x04, 0xb8, 0x98, 0x83, 0x53, 0x0b, 0x25, 0x18, 0x15, 0x18, 0x35,
0x58, 0x82, 0x40, 0x4c, 0x21, 0x15, 0x2e, 0xde, 0xe0, 0xd4, 0xa2, 0xb2, 0xcc, 0xe4, 0x54, 0xdf,
var file_rpc_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 0xd4, 0x92, 0x8c, 0xfc, 0x14, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x54, 0x41, 0x21, 0x09,
var file_rpc_proto_goTypes = []interface{}{ 0x2e, 0x76, 0xbf, 0xfc, 0xa0, 0xd4, 0x82, 0x9c, 0x4a, 0x09, 0x66, 0x05, 0x46, 0x0d, 0x8e, 0x20,
(*PBRpcRequestData)(nil), // 0: rpc.PBRpcRequestData 0x18, 0x17, 0x24, 0xe3, 0x99, 0x17, 0x90, 0x58, 0x94, 0x98, 0x2b, 0xc1, 0xa2, 0xc0, 0xa8, 0xc1,
(*PBRpcResponseData)(nil), // 1: rpc.PBRpcResponseData 0x13, 0x04, 0xe3, 0x2a, 0x05, 0x72, 0x09, 0x42, 0xed, 0x2f, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0xc5,
} 0xe1, 0x00, 0x11, 0x2e, 0x56, 0xd7, 0xa2, 0xa2, 0xfc, 0x22, 0xa8, 0xc5, 0x10, 0x0e, 0x48, 0x14,
var file_rpc_proto_depIdxs = []int32{ 0x61, 0x1d, 0x4f, 0x10, 0x84, 0xe3, 0xc4, 0x1e, 0xc5, 0xaa, 0x67, 0x5d, 0x54, 0x90, 0x9c, 0xc4,
0, // [0:0] is the sub-list for method output_type 0x06, 0xf6, 0xa7, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x5b, 0x74, 0xd8, 0xfd, 0x00, 0x00,
0, // [0:0] is the sub-list for method input_type 0x00,
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_rpc_proto_init() }
func file_rpc_proto_init() {
if File_rpc_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_rpc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PBRpcRequestData); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rpc_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*PBRpcResponseData); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_rpc_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_rpc_proto_goTypes,
DependencyIndexes: file_rpc_proto_depIdxs,
MessageInfos: file_rpc_proto_msgTypes,
}.Build()
File_rpc_proto = out.File
file_rpc_proto_rawDesc = nil
file_rpc_proto_goTypes = nil
file_rpc_proto_depIdxs = nil
} }

View File

@@ -1,16 +1,16 @@
syntax = "proto2"; syntax = "proto3";
package rpc; package rpc;
option go_package =".;rpc"; option go_package =".;rpc";
message PBRpcRequestData{ message PBRpcRequestData{
optional uint64 Seq = 1; uint64 Seq = 1;
optional string ServiceMethod = 2; string ServiceMethod = 2;
optional bool NoReply = 3; bool NoReply = 3;
optional bytes InParam = 4; bytes InParam = 4;
} }
message PBRpcResponseData{ message PBRpcResponseData{
optional uint64 Seq = 1; uint64 Seq = 1;
optional string Error = 2; string Error = 2;
optional bytes Reply = 3; bytes Reply = 3;
} }