Use protobuf enums

This commit is contained in:
Jae Kwon
2016-01-31 19:56:02 -08:00
parent 028cc4aa06
commit 012abc437b
8 changed files with 126 additions and 102 deletions

View File

@ -23,11 +23,56 @@ var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
type MessageType int32
const (
MessageType_NullMessage MessageType = 0
MessageType_Echo MessageType = 1
MessageType_Flush MessageType = 2
MessageType_Info MessageType = 3
MessageType_SetOption MessageType = 4
MessageType_Exception MessageType = 5
MessageType_AppendTx MessageType = 17
MessageType_CheckTx MessageType = 18
MessageType_GetHash MessageType = 19
MessageType_Query MessageType = 20
)
var MessageType_name = map[int32]string{
0: "NullMessage",
1: "Echo",
2: "Flush",
3: "Info",
4: "SetOption",
5: "Exception",
17: "AppendTx",
18: "CheckTx",
19: "GetHash",
20: "Query",
}
var MessageType_value = map[string]int32{
"NullMessage": 0,
"Echo": 1,
"Flush": 2,
"Info": 3,
"SetOption": 4,
"Exception": 5,
"AppendTx": 17,
"CheckTx": 18,
"GetHash": 19,
"Query": 20,
}
func (x MessageType) String() string {
return proto.EnumName(MessageType_name, int32(x))
}
func (MessageType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
type Request struct {
Type uint32 `protobuf:"varint,1,opt,name=type" json:"type,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
Key string `protobuf:"bytes,3,opt,name=key" json:"key,omitempty"`
Value string `protobuf:"bytes,4,opt,name=value" json:"value,omitempty"`
Type MessageType `protobuf:"varint,1,opt,name=type,enum=types.MessageType" json:"type,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
Key string `protobuf:"bytes,3,opt,name=key" json:"key,omitempty"`
Value string `protobuf:"bytes,4,opt,name=value" json:"value,omitempty"`
}
func (m *Request) Reset() { *m = Request{} }
@ -36,11 +81,11 @@ func (*Request) ProtoMessage() {}
func (*Request) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
type Response struct {
Type uint32 `protobuf:"varint,1,opt,name=type" json:"type,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
Code uint32 `protobuf:"varint,3,opt,name=code" json:"code,omitempty"`
Error string `protobuf:"bytes,4,opt,name=error" json:"error,omitempty"`
Log string `protobuf:"bytes,5,opt,name=log" json:"log,omitempty"`
Type MessageType `protobuf:"varint,1,opt,name=type,enum=types.MessageType" json:"type,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
Code uint32 `protobuf:"varint,3,opt,name=code" json:"code,omitempty"`
Error string `protobuf:"bytes,4,opt,name=error" json:"error,omitempty"`
Log string `protobuf:"bytes,5,opt,name=log" json:"log,omitempty"`
}
func (m *Response) Reset() { *m = Response{} }
@ -51,19 +96,27 @@ func (*Response) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1}
func init() {
proto.RegisterType((*Request)(nil), "types.Request")
proto.RegisterType((*Response)(nil), "types.Response")
proto.RegisterEnum("types.MessageType", MessageType_name, MessageType_value)
}
var fileDescriptor0 = []byte{
// 165 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x8f, 0xb1, 0xae, 0xc2, 0x30,
0x0c, 0x45, 0xd5, 0xd7, 0xe6, 0x01, 0x16, 0x48, 0x10, 0x31, 0x64, 0x44, 0x9d, 0x98, 0x60, 0xe0,
0x4f, 0xb2, 0x31, 0x06, 0x6a, 0x31, 0x50, 0xd5, 0x21, 0x49, 0x91, 0xfa, 0xf7, 0xd8, 0xae, 0xd8,
0x59, 0xa2, 0x73, 0x8f, 0xa2, 0xab, 0x6b, 0xd8, 0x95, 0x29, 0x62, 0x3e, 0xeb, 0x7b, 0x8a, 0x89,
0x0a, 0x59, 0xa3, 0xa1, 0xbd, 0xc2, 0xc2, 0xe3, 0x6b, 0xc4, 0x5c, 0xac, 0x85, 0x46, 0x9c, 0xab,
0x0e, 0xd5, 0x71, 0xe3, 0x95, 0xc5, 0x75, 0xa1, 0x04, 0xf7, 0xc7, 0x6e, 0xed, 0x95, 0xed, 0x16,
0xea, 0x27, 0x4e, 0xae, 0x66, 0xb5, 0xf2, 0x82, 0x76, 0x0f, 0xe6, 0x1d, 0xfa, 0x11, 0x5d, 0xa3,
0x6e, 0x0e, 0xed, 0x00, 0x4b, 0x8f, 0x39, 0xd2, 0x90, 0xf1, 0xe7, 0x6e, 0x76, 0x77, 0xea, 0x50,
0xcb, 0xf9, 0x9f, 0xb0, 0xb4, 0x63, 0x4a, 0x94, 0xbe, 0xed, 0x1a, 0x64, 0x45, 0x4f, 0x0f, 0x67,
0xe6, 0x15, 0x8c, 0xb7, 0x7f, 0x3d, 0xec, 0xf2, 0x09, 0x00, 0x00, 0xff, 0xff, 0xce, 0x9d, 0x3d,
0x4f, 0xed, 0x00, 0x00, 0x00,
// 284 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x91, 0x4d, 0x4e, 0xc3, 0x30,
0x10, 0x85, 0x49, 0x9b, 0xd0, 0x64, 0xd2, 0x82, 0x3b, 0x74, 0x91, 0x25, 0xea, 0x02, 0x21, 0x16,
0x45, 0x82, 0x13, 0x20, 0x54, 0x7e, 0x16, 0x80, 0x30, 0xbd, 0x40, 0x48, 0x86, 0x06, 0x35, 0xc4,
0x26, 0xb6, 0x51, 0xb3, 0xe5, 0x00, 0x9c, 0x19, 0xdb, 0x01, 0x89, 0x3d, 0x9b, 0xe8, 0x7d, 0x5f,
0x46, 0xf3, 0x46, 0x32, 0x4c, 0x75, 0x27, 0x49, 0x9d, 0xfa, 0xef, 0x42, 0xb6, 0x42, 0x0b, 0x8c,
0x3c, 0xcc, 0xdf, 0x60, 0xc4, 0xe9, 0xdd, 0x90, 0xd2, 0x78, 0x04, 0xa1, 0x73, 0x59, 0x70, 0x18,
0x1c, 0xef,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