mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #1143 from unihorn/136
*: Id -> ID for protobuf types
This commit is contained in:
commit
0e8345aa73
@ -257,7 +257,7 @@ func parseRequest(r *http.Request, id int64) (etcdserverpb.Request, error) {
|
||||
}
|
||||
|
||||
rr := etcdserverpb.Request{
|
||||
Id: id,
|
||||
ID: id,
|
||||
Method: r.Method,
|
||||
Path: p,
|
||||
Val: r.FormValue("value"),
|
||||
|
@ -222,7 +222,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
// good prefix, all other values default
|
||||
mustNewRequest(t, "foo"),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "GET",
|
||||
Path: "/foo",
|
||||
},
|
||||
@ -235,7 +235,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
url.Values{"value": []string{"some_value"}},
|
||||
),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "PUT",
|
||||
Val: "some_value",
|
||||
Path: "/foo",
|
||||
@ -249,7 +249,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
url.Values{"prevIndex": []string{"98765"}},
|
||||
),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "PUT",
|
||||
PrevIndex: 98765,
|
||||
Path: "/foo",
|
||||
@ -263,7 +263,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
url.Values{"recursive": []string{"true"}},
|
||||
),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "PUT",
|
||||
Recursive: true,
|
||||
Path: "/foo",
|
||||
@ -277,7 +277,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
url.Values{"sorted": []string{"true"}},
|
||||
),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "PUT",
|
||||
Sorted: true,
|
||||
Path: "/foo",
|
||||
@ -287,7 +287,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
// wait specified
|
||||
mustNewRequest(t, "foo?wait=true"),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "GET",
|
||||
Wait: true,
|
||||
Path: "/foo",
|
||||
@ -297,7 +297,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
// empty TTL specified
|
||||
mustNewRequest(t, "foo?ttl="),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "GET",
|
||||
Path: "/foo",
|
||||
Expiration: 0,
|
||||
@ -307,7 +307,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
// dir specified
|
||||
mustNewRequest(t, "foo?dir=true"),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "GET",
|
||||
Dir: true,
|
||||
Path: "/foo",
|
||||
@ -317,7 +317,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
// dir specified negatively
|
||||
mustNewRequest(t, "foo?dir=false"),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "GET",
|
||||
Dir: false,
|
||||
Path: "/foo",
|
||||
@ -331,7 +331,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
url.Values{"prevExist": []string{"true"}},
|
||||
),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "PUT",
|
||||
PrevExist: boolp(true),
|
||||
Path: "/foo",
|
||||
@ -345,7 +345,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
url.Values{"prevExist": []string{"false"}},
|
||||
),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "PUT",
|
||||
PrevExist: boolp(false),
|
||||
Path: "/foo",
|
||||
@ -363,7 +363,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
},
|
||||
),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "PUT",
|
||||
PrevExist: boolp(true),
|
||||
PrevValue: "previous value",
|
||||
@ -379,7 +379,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
url.Values{},
|
||||
),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "PUT",
|
||||
PrevValue: "woof",
|
||||
Path: "/foo",
|
||||
@ -395,7 +395,7 @@ func TestGoodParseRequest(t *testing.T) {
|
||||
},
|
||||
),
|
||||
etcdserverpb.Request{
|
||||
Id: 1234,
|
||||
ID: 1234,
|
||||
Method: "PUT",
|
||||
PrevValue: "miaow",
|
||||
Path: "/foo",
|
||||
|
@ -28,22 +28,22 @@ var _ = &json.SyntaxError{}
|
||||
var _ = math.Inf
|
||||
|
||||
type Request struct {
|
||||
Id int64 `protobuf:"varint,1,req,name=id" json:"id"`
|
||||
Method string `protobuf:"bytes,2,req,name=method" json:"method"`
|
||||
Path string `protobuf:"bytes,3,req,name=path" json:"path"`
|
||||
Val string `protobuf:"bytes,4,req,name=val" json:"val"`
|
||||
Dir bool `protobuf:"varint,5,req,name=dir" json:"dir"`
|
||||
PrevValue string `protobuf:"bytes,6,req,name=prevValue" json:"prevValue"`
|
||||
PrevIndex uint64 `protobuf:"varint,7,req,name=prevIndex" json:"prevIndex"`
|
||||
PrevExist *bool `protobuf:"varint,8,req,name=prevExist" json:"prevExist,omitempty"`
|
||||
Expiration int64 `protobuf:"varint,9,req,name=expiration" json:"expiration"`
|
||||
Wait bool `protobuf:"varint,10,req,name=wait" json:"wait"`
|
||||
Since uint64 `protobuf:"varint,11,req,name=since" json:"since"`
|
||||
Recursive bool `protobuf:"varint,12,req,name=recursive" json:"recursive"`
|
||||
Sorted bool `protobuf:"varint,13,req,name=sorted" json:"sorted"`
|
||||
Quorum bool `protobuf:"varint,14,req,name=quorum" json:"quorum"`
|
||||
Time int64 `protobuf:"varint,15,req,name=time" json:"time"`
|
||||
Stream bool `protobuf:"varint,16,req,name=stream" json:"stream"`
|
||||
ID int64 `protobuf:"varint,1,req" json:"ID"`
|
||||
Method string `protobuf:"bytes,2,req" json:"Method"`
|
||||
Path string `protobuf:"bytes,3,req" json:"Path"`
|
||||
Val string `protobuf:"bytes,4,req" json:"Val"`
|
||||
Dir bool `protobuf:"varint,5,req" json:"Dir"`
|
||||
PrevValue string `protobuf:"bytes,6,req" json:"PrevValue"`
|
||||
PrevIndex uint64 `protobuf:"varint,7,req" json:"PrevIndex"`
|
||||
PrevExist *bool `protobuf:"varint,8,req" json:"PrevExist,omitempty"`
|
||||
Expiration int64 `protobuf:"varint,9,req" json:"Expiration"`
|
||||
Wait bool `protobuf:"varint,10,req" json:"Wait"`
|
||||
Since uint64 `protobuf:"varint,11,req" json:"Since"`
|
||||
Recursive bool `protobuf:"varint,12,req" json:"Recursive"`
|
||||
Sorted bool `protobuf:"varint,13,req" json:"Sorted"`
|
||||
Quorum bool `protobuf:"varint,14,req" json:"Quorum"`
|
||||
Time int64 `protobuf:"varint,15,req" json:"Time"`
|
||||
Stream bool `protobuf:"varint,16,req" json:"Stream"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ func (m *Request) Unmarshal(data []byte) error {
|
||||
}
|
||||
b := data[index]
|
||||
index++
|
||||
m.Id |= (int64(b) & 0x7F) << shift
|
||||
m.ID |= (int64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
@ -381,7 +381,7 @@ func (m *Request) Unmarshal(data []byte) error {
|
||||
func (m *Request) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
n += 1 + sovEtcdserver(uint64(m.Id))
|
||||
n += 1 + sovEtcdserver(uint64(m.ID))
|
||||
l = len(m.Method)
|
||||
n += 1 + l + sovEtcdserver(uint64(l))
|
||||
l = len(m.Path)
|
||||
@ -439,7 +439,7 @@ func (m *Request) MarshalTo(data []byte) (n int, err error) {
|
||||
_ = l
|
||||
data[i] = 0x8
|
||||
i++
|
||||
i = encodeVarintEtcdserver(data, i, uint64(m.Id))
|
||||
i = encodeVarintEtcdserver(data, i, uint64(m.ID))
|
||||
data[i] = 0x12
|
||||
i++
|
||||
i = encodeVarintEtcdserver(data, i, uint64(len(m.Method)))
|
||||
|
@ -8,20 +8,20 @@ option (gogoproto.unmarshaler_all) = true;
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
message Request {
|
||||
required int64 id = 1 [(gogoproto.nullable) = false];
|
||||
required string method = 2 [(gogoproto.nullable) = false];
|
||||
required string path = 3 [(gogoproto.nullable) = false];
|
||||
required string val = 4 [(gogoproto.nullable) = false];
|
||||
required bool dir = 5 [(gogoproto.nullable) = false];
|
||||
required string prevValue = 6 [(gogoproto.nullable) = false];
|
||||
required uint64 prevIndex = 7 [(gogoproto.nullable) = false];
|
||||
required bool prevExist = 8 [(gogoproto.nullable) = true];
|
||||
required int64 expiration = 9 [(gogoproto.nullable) = false];
|
||||
required bool wait = 10 [(gogoproto.nullable) = false];
|
||||
required uint64 since = 11 [(gogoproto.nullable) = false];
|
||||
required bool recursive = 12 [(gogoproto.nullable) = false];
|
||||
required bool sorted = 13 [(gogoproto.nullable) = false];
|
||||
required bool quorum = 14 [(gogoproto.nullable) = false];
|
||||
required int64 time = 15 [(gogoproto.nullable) = false];
|
||||
required bool stream = 16 [(gogoproto.nullable) = false];
|
||||
required int64 ID = 1 [(gogoproto.nullable) = false];
|
||||
required string Method = 2 [(gogoproto.nullable) = false];
|
||||
required string Path = 3 [(gogoproto.nullable) = false];
|
||||
required string Val = 4 [(gogoproto.nullable) = false];
|
||||
required bool Dir = 5 [(gogoproto.nullable) = false];
|
||||
required string PrevValue = 6 [(gogoproto.nullable) = false];
|
||||
required uint64 PrevIndex = 7 [(gogoproto.nullable) = false];
|
||||
required bool PrevExist = 8 [(gogoproto.nullable) = true];
|
||||
required int64 Expiration = 9 [(gogoproto.nullable) = false];
|
||||
required bool Wait = 10 [(gogoproto.nullable) = false];
|
||||
required uint64 Since = 11 [(gogoproto.nullable) = false];
|
||||
required bool Recursive = 12 [(gogoproto.nullable) = false];
|
||||
required bool Sorted = 13 [(gogoproto.nullable) = false];
|
||||
required bool Quorum = 14 [(gogoproto.nullable) = false];
|
||||
required int64 Time = 15 [(gogoproto.nullable) = false];
|
||||
required bool Stream = 16 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ func (s *EtcdServer) run() {
|
||||
if err := r.Unmarshal(e.Data); err != nil {
|
||||
panic("TODO: this is bad, what do we do about it?")
|
||||
}
|
||||
s.w.Trigger(r.Id, s.apply(r))
|
||||
s.w.Trigger(r.ID, s.apply(r))
|
||||
case raftpb.EntryConfChange:
|
||||
var cc raftpb.ConfChange
|
||||
if err := cc.Unmarshal(e.Data); err != nil {
|
||||
@ -203,7 +203,7 @@ func (s *EtcdServer) Stop() {
|
||||
// respective operation. Do will block until an action is performed or there is
|
||||
// an error.
|
||||
func (s *EtcdServer) Do(ctx context.Context, r pb.Request) (Response, error) {
|
||||
if r.Id == 0 {
|
||||
if r.ID == 0 {
|
||||
panic("r.Id cannot be 0")
|
||||
}
|
||||
if r.Method == "GET" && r.Quorum {
|
||||
@ -215,14 +215,14 @@ func (s *EtcdServer) Do(ctx context.Context, r pb.Request) (Response, error) {
|
||||
if err != nil {
|
||||
return Response{}, err
|
||||
}
|
||||
ch := s.w.Register(r.Id)
|
||||
ch := s.w.Register(r.ID)
|
||||
s.Node.Propose(ctx, data)
|
||||
select {
|
||||
case x := <-ch:
|
||||
resp := x.(Response)
|
||||
return resp, resp.err
|
||||
case <-ctx.Done():
|
||||
s.w.Trigger(r.Id, nil) // GC wait
|
||||
s.w.Trigger(r.ID, nil) // GC wait
|
||||
return Response{}, ctx.Err()
|
||||
case <-s.done:
|
||||
return Response{}, ErrStopped
|
||||
@ -302,7 +302,7 @@ func (s *EtcdServer) sync(timeout time.Duration) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
req := pb.Request{
|
||||
Method: "SYNC",
|
||||
Id: GenID(),
|
||||
ID: GenID(),
|
||||
Time: time.Now().UnixNano(),
|
||||
}
|
||||
data, err := req.Marshal()
|
||||
|
@ -55,11 +55,11 @@ func TestDoLocalAction(t *testing.T) {
|
||||
wactions []action
|
||||
}{
|
||||
{
|
||||
pb.Request{Method: "GET", Id: 1, Wait: true},
|
||||
pb.Request{Method: "GET", ID: 1, Wait: true},
|
||||
Response{Watcher: &stubWatcher{}}, nil, []action{action{name: "Watch"}},
|
||||
},
|
||||
{
|
||||
pb.Request{Method: "GET", Id: 1},
|
||||
pb.Request{Method: "GET", ID: 1},
|
||||
Response{Event: &store.Event{}}, nil,
|
||||
[]action{
|
||||
action{
|
||||
@ -69,7 +69,7 @@ func TestDoLocalAction(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pb.Request{Method: "BADMETHOD", Id: 1},
|
||||
pb.Request{Method: "BADMETHOD", ID: 1},
|
||||
Response{}, ErrUnknownMethod, []action{},
|
||||
},
|
||||
}
|
||||
@ -101,11 +101,11 @@ func TestDoBadLocalAction(t *testing.T) {
|
||||
wactions []action
|
||||
}{
|
||||
{
|
||||
pb.Request{Method: "GET", Id: 1, Wait: true},
|
||||
pb.Request{Method: "GET", ID: 1, Wait: true},
|
||||
[]action{action{name: "Watch"}},
|
||||
},
|
||||
{
|
||||
pb.Request{Method: "GET", Id: 1},
|
||||
pb.Request{Method: "GET", ID: 1},
|
||||
[]action{action{name: "Get"}},
|
||||
},
|
||||
}
|
||||
@ -136,7 +136,7 @@ func TestApply(t *testing.T) {
|
||||
}{
|
||||
// POST ==> Create
|
||||
{
|
||||
pb.Request{Method: "POST", Id: 1},
|
||||
pb.Request{Method: "POST", ID: 1},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -147,7 +147,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// POST ==> Create, with expiration
|
||||
{
|
||||
pb.Request{Method: "POST", Id: 1, Expiration: 1337},
|
||||
pb.Request{Method: "POST", ID: 1, Expiration: 1337},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -158,7 +158,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// POST ==> Create, with dir
|
||||
{
|
||||
pb.Request{Method: "POST", Id: 1, Dir: true},
|
||||
pb.Request{Method: "POST", ID: 1, Dir: true},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -169,7 +169,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// PUT ==> Set
|
||||
{
|
||||
pb.Request{Method: "PUT", Id: 1},
|
||||
pb.Request{Method: "PUT", ID: 1},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -180,7 +180,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// PUT ==> Set, with dir
|
||||
{
|
||||
pb.Request{Method: "PUT", Id: 1, Dir: true},
|
||||
pb.Request{Method: "PUT", ID: 1, Dir: true},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -191,7 +191,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// PUT with PrevExist=true ==> Update
|
||||
{
|
||||
pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(true)},
|
||||
pb.Request{Method: "PUT", ID: 1, PrevExist: boolp(true)},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -202,7 +202,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// PUT with PrevExist=false ==> Create
|
||||
{
|
||||
pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(false)},
|
||||
pb.Request{Method: "PUT", ID: 1, PrevExist: boolp(false)},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -214,7 +214,7 @@ func TestApply(t *testing.T) {
|
||||
// PUT with PrevExist=true *and* PrevIndex set ==> Update
|
||||
// TODO(jonboulle): is this expected?!
|
||||
{
|
||||
pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(true), PrevIndex: 1},
|
||||
pb.Request{Method: "PUT", ID: 1, PrevExist: boolp(true), PrevIndex: 1},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -226,7 +226,7 @@ func TestApply(t *testing.T) {
|
||||
// PUT with PrevExist=false *and* PrevIndex set ==> Create
|
||||
// TODO(jonboulle): is this expected?!
|
||||
{
|
||||
pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(false), PrevIndex: 1},
|
||||
pb.Request{Method: "PUT", ID: 1, PrevExist: boolp(false), PrevIndex: 1},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -237,7 +237,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// PUT with PrevIndex set ==> CompareAndSwap
|
||||
{
|
||||
pb.Request{Method: "PUT", Id: 1, PrevIndex: 1},
|
||||
pb.Request{Method: "PUT", ID: 1, PrevIndex: 1},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -248,7 +248,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// PUT with PrevValue set ==> CompareAndSwap
|
||||
{
|
||||
pb.Request{Method: "PUT", Id: 1, PrevValue: "bar"},
|
||||
pb.Request{Method: "PUT", ID: 1, PrevValue: "bar"},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -259,7 +259,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// PUT with PrevIndex and PrevValue set ==> CompareAndSwap
|
||||
{
|
||||
pb.Request{Method: "PUT", Id: 1, PrevIndex: 1, PrevValue: "bar"},
|
||||
pb.Request{Method: "PUT", ID: 1, PrevIndex: 1, PrevValue: "bar"},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -270,7 +270,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// DELETE ==> Delete
|
||||
{
|
||||
pb.Request{Method: "DELETE", Id: 1},
|
||||
pb.Request{Method: "DELETE", ID: 1},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -281,7 +281,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// DELETE with PrevIndex set ==> CompareAndDelete
|
||||
{
|
||||
pb.Request{Method: "DELETE", Id: 1, PrevIndex: 1},
|
||||
pb.Request{Method: "DELETE", ID: 1, PrevIndex: 1},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -292,7 +292,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// DELETE with PrevValue set ==> CompareAndDelete
|
||||
{
|
||||
pb.Request{Method: "DELETE", Id: 1, PrevValue: "bar"},
|
||||
pb.Request{Method: "DELETE", ID: 1, PrevValue: "bar"},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -303,7 +303,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// DELETE with PrevIndex *and* PrevValue set ==> CompareAndDelete
|
||||
{
|
||||
pb.Request{Method: "DELETE", Id: 1, PrevIndex: 5, PrevValue: "bar"},
|
||||
pb.Request{Method: "DELETE", ID: 1, PrevIndex: 5, PrevValue: "bar"},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -314,7 +314,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// QGET ==> Get
|
||||
{
|
||||
pb.Request{Method: "QGET", Id: 1},
|
||||
pb.Request{Method: "QGET", ID: 1},
|
||||
Response{Event: &store.Event{}},
|
||||
[]action{
|
||||
action{
|
||||
@ -325,7 +325,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// SYNC ==> DeleteExpiredKeys
|
||||
{
|
||||
pb.Request{Method: "SYNC", Id: 1},
|
||||
pb.Request{Method: "SYNC", ID: 1},
|
||||
Response{},
|
||||
[]action{
|
||||
action{
|
||||
@ -335,7 +335,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
pb.Request{Method: "SYNC", Id: 1, Time: 12345},
|
||||
pb.Request{Method: "SYNC", ID: 1, Time: 12345},
|
||||
Response{},
|
||||
[]action{
|
||||
action{
|
||||
@ -346,7 +346,7 @@ func TestApply(t *testing.T) {
|
||||
},
|
||||
// Unknown method - error
|
||||
{
|
||||
pb.Request{Method: "BADMETHOD", Id: 1},
|
||||
pb.Request{Method: "BADMETHOD", ID: 1},
|
||||
Response{err: ErrUnknownMethod},
|
||||
[]action{},
|
||||
},
|
||||
@ -410,7 +410,7 @@ func testServer(t *testing.T, ns int64) {
|
||||
for i := 1; i <= 10; i++ {
|
||||
r := pb.Request{
|
||||
Method: "PUT",
|
||||
Id: int64(i),
|
||||
ID: int64(i),
|
||||
Path: "/foo",
|
||||
Val: "bar",
|
||||
}
|
||||
@ -449,10 +449,10 @@ func testServer(t *testing.T, ns int64) {
|
||||
|
||||
func TestDoProposal(t *testing.T) {
|
||||
tests := []pb.Request{
|
||||
pb.Request{Method: "POST", Id: 1},
|
||||
pb.Request{Method: "PUT", Id: 1},
|
||||
pb.Request{Method: "DELETE", Id: 1},
|
||||
pb.Request{Method: "GET", Id: 1, Quorum: true},
|
||||
pb.Request{Method: "POST", ID: 1},
|
||||
pb.Request{Method: "PUT", ID: 1},
|
||||
pb.Request{Method: "DELETE", ID: 1},
|
||||
pb.Request{Method: "GET", ID: 1, Quorum: true},
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
@ -503,7 +503,7 @@ func TestDoProposalCancelled(t *testing.T) {
|
||||
done := make(chan struct{})
|
||||
var err error
|
||||
go func() {
|
||||
_, err = srv.Do(ctx, pb.Request{Method: "PUT", Id: 1})
|
||||
_, err = srv.Do(ctx, pb.Request{Method: "PUT", ID: 1})
|
||||
close(done)
|
||||
}()
|
||||
cancel()
|
||||
@ -544,7 +544,7 @@ func TestDoProposalStopped(t *testing.T) {
|
||||
done := make(chan struct{})
|
||||
var err error
|
||||
go func() {
|
||||
_, err = srv.Do(ctx, pb.Request{Method: "PUT", Id: 1})
|
||||
_, err = srv.Do(ctx, pb.Request{Method: "PUT", ID: 1})
|
||||
close(done)
|
||||
}()
|
||||
srv.Stop()
|
||||
@ -712,7 +712,7 @@ func TestTriggerSnap(t *testing.T) {
|
||||
|
||||
s.Start()
|
||||
for i := 0; int64(i) < s.SnapCount; i++ {
|
||||
s.Do(ctx, pb.Request{Method: "PUT", Id: 1})
|
||||
s.Do(ctx, pb.Request{Method: "PUT", ID: 1})
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
s.Stop()
|
||||
|
@ -99,7 +99,7 @@ func (x *ConfChangeType) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
type Info struct {
|
||||
Id int64 `protobuf:"varint,1,req,name=id" json:"id"`
|
||||
ID int64 `protobuf:"varint,1,req" json:"ID"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ func (m *Info) Unmarshal(data []byte) error {
|
||||
}
|
||||
b := data[index]
|
||||
index++
|
||||
m.Id |= (int64(b) & 0x7F) << shift
|
||||
m.ID |= (int64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
@ -863,7 +863,7 @@ func (m *ConfChange) Unmarshal(data []byte) error {
|
||||
func (m *Info) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
n += 1 + sovRaft(uint64(m.Id))
|
||||
n += 1 + sovRaft(uint64(m.ID))
|
||||
if m.XXX_unrecognized != nil {
|
||||
n += len(m.XXX_unrecognized)
|
||||
}
|
||||
@ -978,7 +978,7 @@ func (m *Info) MarshalTo(data []byte) (n int, err error) {
|
||||
_ = l
|
||||
data[i] = 0x8
|
||||
i++
|
||||
i = encodeVarintRaft(data, i, uint64(m.Id))
|
||||
i = encodeVarintRaft(data, i, uint64(m.ID))
|
||||
if m.XXX_unrecognized != nil {
|
||||
i += copy(data[i:], m.XXX_unrecognized)
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ option (gogoproto.goproto_getters_all) = false;
|
||||
option (gogoproto.goproto_enum_prefix_all) = false;
|
||||
|
||||
message Info {
|
||||
required int64 id = 1 [(gogoproto.nullable) = false];
|
||||
required int64 ID = 1 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
enum EntryType {
|
||||
|
@ -170,11 +170,11 @@ func (w *WAL) ReadAll() (id int64, state raftpb.HardState, ents []raftpb.Entry,
|
||||
state = mustUnmarshalState(rec.Data)
|
||||
case infoType:
|
||||
i := mustUnmarshalInfo(rec.Data)
|
||||
if id != 0 && id != i.Id {
|
||||
if id != 0 && id != i.ID {
|
||||
state.Reset()
|
||||
return 0, state, nil, ErrIDMismatch
|
||||
}
|
||||
id = i.Id
|
||||
id = i.ID
|
||||
case crcType:
|
||||
crc := decoder.crc.Sum32()
|
||||
// current crc of decoder must match the crc of the record.
|
||||
|
@ -165,7 +165,7 @@ func TestRecover(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
i := &raftpb.Info{Id: int64(0xBAD0)}
|
||||
i := &raftpb.Info{ID: int64(0xBAD0)}
|
||||
if err = w.SaveInfo(i); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -191,8 +191,8 @@ func TestRecover(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if id != i.Id {
|
||||
t.Errorf("id = %d, want %d", id, i.Id)
|
||||
if id != i.ID {
|
||||
t.Errorf("id = %d, want %d", id, i.ID)
|
||||
}
|
||||
if !reflect.DeepEqual(entries, ents) {
|
||||
t.Errorf("ents = %+v, want %+v", entries, ents)
|
||||
@ -282,7 +282,7 @@ func TestRecoverAfterCut(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
info := &raftpb.Info{Id: int64(0xBAD1)}
|
||||
info := &raftpb.Info{ID: int64(0xBAD1)}
|
||||
if err = w.SaveInfo(info); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -328,8 +328,8 @@ func TestRecoverAfterCut(t *testing.T) {
|
||||
t.Errorf("#%d: err = %v, want nil", i, err)
|
||||
continue
|
||||
}
|
||||
if id != info.Id {
|
||||
t.Errorf("#%d: id = %d, want %d", i, id, info.Id)
|
||||
if id != info.ID {
|
||||
t.Errorf("#%d: id = %d, want %d", i, id, info.ID)
|
||||
}
|
||||
for j, e := range entries {
|
||||
if e.Index != int64(j+i) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user