Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update to latest protobuf

  • Loading branch information...
commit bb4b11f6e00afd69e1a998af2d5c33dd92b47b8f 1 parent cd7b918
@mreiferson mreiferson authored
View
16 consensus/m.go
@@ -1,14 +1,14 @@
package consensus
var (
- nop = newMsg_Cmd(msg_NOP)
- invite = newMsg_Cmd(msg_INVITE)
- rsvp = newMsg_Cmd(msg_RSVP)
- nominate = newMsg_Cmd(msg_NOMINATE)
- vote = newMsg_Cmd(msg_VOTE)
- tick = newMsg_Cmd(msg_TICK)
- propose = newMsg_Cmd(msg_PROPOSE)
- learn = newMsg_Cmd(msg_LEARN)
+ nop = msg_NOP.Enum()
+ invite = msg_INVITE.Enum()
+ rsvp = msg_RSVP.Enum()
+ nominate = msg_NOMINATE.Enum()
+ vote = msg_VOTE.Enum()
+ tick = msg_TICK.Enum()
+ propose = msg_PROPOSE.Enum()
+ learn = msg_LEARN.Enum()
)
const nmsg = 8
View
67 consensus/m.pb.go
@@ -1,13 +1,16 @@
-// Code generated by protoc-gen-go from "m.proto"
+// Code generated by protoc-gen-go.
+// source: m.proto
// DO NOT EDIT!
package consensus
import proto "code.google.com/p/goprotobuf/proto"
-import "math"
+import json "encoding/json"
+import math "math"
-// Reference proto and math imports to suppress error if they are not otherwise used.
-var _ = proto.GetString
+// 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 msg_Cmd int32
@@ -44,13 +47,25 @@ var msg_Cmd_value = map[string]int32{
"LEARN": 7,
}
-func newMsg_Cmd(x msg_Cmd) *msg_Cmd {
- e := msg_Cmd(x)
- return &e
+func (x msg_Cmd) Enum() *msg_Cmd {
+ p := new(msg_Cmd)
+ *p = x
+ return p
}
func (x msg_Cmd) String() string {
return proto.EnumName(msg_Cmd_name, int32(x))
}
+func (x msg_Cmd) MarshalJSON() ([]byte, error) {
+ return json.Marshal(x.String())
+}
+func (x *msg_Cmd) UnmarshalJSON(data []byte) error {
+ value, err := proto.UnmarshalJSONEnum(msg_Cmd_value, data, "msg_Cmd")
+ if err != nil {
+ return err
+ }
+ *x = msg_Cmd(value)
+ return nil
+}
type msg struct {
Cmd *msg_Cmd `protobuf:"varint,1,opt,name=cmd,enum=consensus.msg_Cmd" json:"cmd,omitempty"`
@@ -58,11 +73,47 @@ type msg struct {
Crnd *int64 `protobuf:"varint,3,opt,name=crnd" json:"crnd,omitempty"`
Vrnd *int64 `protobuf:"varint,4,opt,name=vrnd" json:"vrnd,omitempty"`
Value []byte `protobuf:"bytes,5,opt,name=value" json:"value,omitempty"`
- XXX_unrecognized []byte `json:",omitempty"`
+ XXX_unrecognized []byte `json:"-"`
}
func (this *msg) Reset() { *this = msg{} }
func (this *msg) String() string { return proto.CompactTextString(this) }
+func (*msg) ProtoMessage() {}
+
+func (this *msg) GetCmd() msg_Cmd {
+ if this != nil && this.Cmd != nil {
+ return *this.Cmd
+ }
+ return 0
+}
+
+func (this *msg) GetSeqn() int64 {
+ if this != nil && this.Seqn != nil {
+ return *this.Seqn
+ }
+ return 0
+}
+
+func (this *msg) GetCrnd() int64 {
+ if this != nil && this.Crnd != nil {
+ return *this.Crnd
+ }
+ return 0
+}
+
+func (this *msg) GetVrnd() int64 {
+ if this != nil && this.Vrnd != nil {
+ return *this.Vrnd
+ }
+ return 0
+}
+
+func (this *msg) GetValue() []byte {
+ if this != nil {
+ return this.Value
+ }
+ return nil
+}
func init() {
proto.RegisterEnum("consensus.msg_Cmd", msg_Cmd_name, msg_Cmd_value)
View
2  consensus/manager_test.go
@@ -17,7 +17,7 @@ import (
// http://code.google.com/apis/protocolbuffers/docs/encoding.html#varints.
var invalidProtobuf = []byte{0x80}
-func mustMarshal(p interface{}) []byte {
+func mustMarshal(p proto.Message) []byte {
buf, err := proto.Marshal(p)
if err != nil {
panic(err)
View
2  server/Makefile
@@ -6,5 +6,5 @@ msg.pb.go: msg.proto
|sed s/Response/response/g\
|sed s/Newrequest/newRequest/g\
|sed s/Newresponse/newResponse/g\
- |gofmt >$@
+ >$@
rm -rf _pb
View
189 server/msg.pb.go
@@ -1,15 +1,17 @@
-// Code generated by protoc-gen-go from "msg.proto"
+// Code generated by protoc-gen-go.
+// source: msg.proto
// DO NOT EDIT!
package server
import proto "code.google.com/p/goprotobuf/proto"
-import "math"
+import json "encoding/json"
+import math "math"
-// Reference proto, math & os imports to suppress error if they are not otherwise used.
-var _ = proto.GetString
+// Reference proto, json, and math imports to suppress error if they are not otherwise used.
+var _ = proto.Marshal
+var _ = &json.SyntaxError{}
var _ = math.Inf
-var _ error
type request_Verb int32
@@ -51,13 +53,25 @@ var request_Verb_value = map[string]int32{
"ACCESS": 99,
}
-func newRequest_Verb(x request_Verb) *request_Verb {
- e := request_Verb(x)
- return &e
+func (x request_Verb) Enum() *request_Verb {
+ p := new(request_Verb)
+ *p = x
+ return p
}
func (x request_Verb) String() string {
return proto.EnumName(request_Verb_name, int32(x))
}
+func (x request_Verb) MarshalJSON() ([]byte, error) {
+ return json.Marshal(x.String())
+}
+func (x *request_Verb) UnmarshalJSON(data []byte) error {
+ value, err := proto.UnmarshalJSONEnum(request_Verb_value, data, "request_Verb")
+ if err != nil {
+ return err
+ }
+ *x = request_Verb(value)
+ return nil
+}
type response_Err int32
@@ -105,42 +119,161 @@ var response_Err_value = map[string]int32{
"NOENT": 22,
}
-func newResponse_Err(x response_Err) *response_Err {
- e := response_Err(x)
- return &e
+func (x response_Err) Enum() *response_Err {
+ p := new(response_Err)
+ *p = x
+ return p
}
func (x response_Err) String() string {
return proto.EnumName(response_Err_name, int32(x))
}
+func (x response_Err) MarshalJSON() ([]byte, error) {
+ return json.Marshal(x.String())
+}
+func (x *response_Err) UnmarshalJSON(data []byte) error {
+ value, err := proto.UnmarshalJSONEnum(response_Err_value, data, "response_Err")
+ if err != nil {
+ return err
+ }
+ *x = response_Err(value)
+ return nil
+}
type request struct {
- Tag *int32 `protobuf:"varint,1,opt,name=tag" json:"tag"`
- Verb *request_Verb `protobuf:"varint,2,opt,name=verb,enum=server.request_Verb" json:"verb"`
- Path *string `protobuf:"bytes,4,opt,name=path" json:"path"`
- Value []byte `protobuf:"bytes,5,opt,name=value" json:"value"`
- OtherTag *int32 `protobuf:"varint,6,opt,name=other_tag" json:"other_tag"`
- Offset *int32 `protobuf:"varint,7,opt,name=offset" json:"offset"`
- Rev *int64 `protobuf:"varint,9,opt,name=rev" json:"rev"`
- XXX_unrecognized []byte
+ Tag *int32 `protobuf:"varint,1,opt,name=tag" json:"tag,omitempty"`
+ Verb *request_Verb `protobuf:"varint,2,opt,name=verb,enum=server.request_Verb" json:"verb,omitempty"`
+ Path *string `protobuf:"bytes,4,opt,name=path" json:"path,omitempty"`
+ Value []byte `protobuf:"bytes,5,opt,name=value" json:"value,omitempty"`
+ OtherTag *int32 `protobuf:"varint,6,opt,name=other_tag" json:"other_tag,omitempty"`
+ Offset *int32 `protobuf:"varint,7,opt,name=offset" json:"offset,omitempty"`
+ Rev *int64 `protobuf:"varint,9,opt,name=rev" json:"rev,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
}
func (this *request) Reset() { *this = request{} }
func (this *request) String() string { return proto.CompactTextString(this) }
+func (*request) ProtoMessage() {}
+
+func (this *request) GetTag() int32 {
+ if this != nil && this.Tag != nil {
+ return *this.Tag
+ }
+ return 0
+}
+
+func (this *request) GetVerb() request_Verb {
+ if this != nil && this.Verb != nil {
+ return *this.Verb
+ }
+ return 0
+}
+
+func (this *request) GetPath() string {
+ if this != nil && this.Path != nil {
+ return *this.Path
+ }
+ return ""
+}
+
+func (this *request) GetValue() []byte {
+ if this != nil {
+ return this.Value
+ }
+ return nil
+}
+
+func (this *request) GetOtherTag() int32 {
+ if this != nil && this.OtherTag != nil {
+ return *this.OtherTag
+ }
+ return 0
+}
+
+func (this *request) GetOffset() int32 {
+ if this != nil && this.Offset != nil {
+ return *this.Offset
+ }
+ return 0
+}
+
+func (this *request) GetRev() int64 {
+ if this != nil && this.Rev != nil {
+ return *this.Rev
+ }
+ return 0
+}
type response struct {
- Tag *int32 `protobuf:"varint,1,opt,name=tag" json:"tag"`
- Flags *int32 `protobuf:"varint,2,opt,name=flags" json:"flags"`
- Rev *int64 `protobuf:"varint,3,opt,name=rev" json:"rev"`
- Path *string `protobuf:"bytes,5,opt,name=path" json:"path"`
- Value []byte `protobuf:"bytes,6,opt,name=value" json:"value"`
- Len *int32 `protobuf:"varint,8,opt,name=len" json:"len"`
- ErrCode *response_Err `protobuf:"varint,100,opt,name=err_code,enum=server.response_Err" json:"err_code"`
- ErrDetail *string `protobuf:"bytes,101,opt,name=err_detail" json:"err_detail"`
- XXX_unrecognized []byte
+ Tag *int32 `protobuf:"varint,1,opt,name=tag" json:"tag,omitempty"`
+ Flags *int32 `protobuf:"varint,2,opt,name=flags" json:"flags,omitempty"`
+ Rev *int64 `protobuf:"varint,3,opt,name=rev" json:"rev,omitempty"`
+ Path *string `protobuf:"bytes,5,opt,name=path" json:"path,omitempty"`
+ Value []byte `protobuf:"bytes,6,opt,name=value" json:"value,omitempty"`
+ Len *int32 `protobuf:"varint,8,opt,name=len" json:"len,omitempty"`
+ ErrCode *response_Err `protobuf:"varint,100,opt,name=err_code,enum=server.response_Err" json:"err_code,omitempty"`
+ ErrDetail *string `protobuf:"bytes,101,opt,name=err_detail" json:"err_detail,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
}
func (this *response) Reset() { *this = response{} }
func (this *response) String() string { return proto.CompactTextString(this) }
+func (*response) ProtoMessage() {}
+
+func (this *response) GetTag() int32 {
+ if this != nil && this.Tag != nil {
+ return *this.Tag
+ }
+ return 0
+}
+
+func (this *response) GetFlags() int32 {
+ if this != nil && this.Flags != nil {
+ return *this.Flags
+ }
+ return 0
+}
+
+func (this *response) GetRev() int64 {
+ if this != nil && this.Rev != nil {
+ return *this.Rev
+ }
+ return 0
+}
+
+func (this *response) GetPath() string {
+ if this != nil && this.Path != nil {
+ return *this.Path
+ }
+ return ""
+}
+
+func (this *response) GetValue() []byte {
+ if this != nil {
+ return this.Value
+ }
+ return nil
+}
+
+func (this *response) GetLen() int32 {
+ if this != nil && this.Len != nil {
+ return *this.Len
+ }
+ return 0
+}
+
+func (this *response) GetErrCode() response_Err {
+ if this != nil && this.ErrCode != nil {
+ return *this.ErrCode
+ }
+ return 0
+}
+
+func (this *response) GetErrDetail() string {
+ if this != nil && this.ErrDetail != nil {
+ return *this.ErrDetail
+ }
+ return ""
+}
func init() {
proto.RegisterEnum("server.request_Verb", request_Verb_name, request_Verb_value)
View
4 server/txn.go
@@ -38,7 +38,7 @@ const (
)
func (t *txn) run() {
- verb := proto.GetInt32((*int32)(t.req.Verb))
+ verb := int32(t.req.GetVerb())
if f, ok := ops[verb]; ok {
f(t)
} else {
@@ -167,7 +167,7 @@ func (t *txn) stat() {
return
}
- len, rev := g.Stat(proto.GetString(t.req.Path))
+ len, rev := g.Stat(t.req.GetPath())
t.resp.Len = &len
t.resp.Rev = &rev
t.respond()
Please sign in to comment.
Something went wrong with that request. Please try again.