mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
clientv3,ctlv3: following changes for proto change
This commit is contained in:
parent
6e149e3485
commit
1e4d3603db
@ -53,7 +53,7 @@ type Op struct {
|
||||
leaseID LeaseID
|
||||
}
|
||||
|
||||
func (op Op) toRequestUnion() *pb.RequestUnion {
|
||||
func (op Op) toRequestOp() *pb.RequestOp {
|
||||
switch op.t {
|
||||
case tRange:
|
||||
r := &pb.RangeRequest{Key: op.key, RangeEnd: op.end, Limit: op.limit, Revision: op.rev, Serializable: op.serializable}
|
||||
@ -61,13 +61,13 @@ func (op Op) toRequestUnion() *pb.RequestUnion {
|
||||
r.SortOrder = pb.RangeRequest_SortOrder(op.sort.Order)
|
||||
r.SortTarget = pb.RangeRequest_SortTarget(op.sort.Target)
|
||||
}
|
||||
return &pb.RequestUnion{Request: &pb.RequestUnion_RequestRange{RequestRange: r}}
|
||||
return &pb.RequestOp{Request: &pb.RequestOp_RequestRange{RequestRange: r}}
|
||||
case tPut:
|
||||
r := &pb.PutRequest{Key: op.key, Value: op.val, Lease: int64(op.leaseID)}
|
||||
return &pb.RequestUnion{Request: &pb.RequestUnion_RequestPut{RequestPut: r}}
|
||||
return &pb.RequestOp{Request: &pb.RequestOp_RequestPut{RequestPut: r}}
|
||||
case tDeleteRange:
|
||||
r := &pb.DeleteRangeRequest{Key: op.key, RangeEnd: op.end}
|
||||
return &pb.RequestUnion{Request: &pb.RequestUnion_RequestDeleteRange{RequestDeleteRange: r}}
|
||||
return &pb.RequestOp{Request: &pb.RequestOp_RequestDeleteRange{RequestDeleteRange: r}}
|
||||
default:
|
||||
panic("Unknown Op")
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ type txn struct {
|
||||
|
||||
cmps []*pb.Compare
|
||||
|
||||
sus []*pb.RequestUnion
|
||||
fas []*pb.RequestUnion
|
||||
sus []*pb.RequestOp
|
||||
fas []*pb.RequestOp
|
||||
}
|
||||
|
||||
func (txn *txn) If(cs ...Cmp) Txn {
|
||||
@ -110,7 +110,7 @@ func (txn *txn) Then(ops ...Op) Txn {
|
||||
|
||||
for _, op := range ops {
|
||||
txn.isWrite = txn.isWrite || op.isWrite()
|
||||
txn.sus = append(txn.sus, op.toRequestUnion())
|
||||
txn.sus = append(txn.sus, op.toRequestOp())
|
||||
}
|
||||
|
||||
return txn
|
||||
@ -128,7 +128,7 @@ func (txn *txn) Else(ops ...Op) Txn {
|
||||
|
||||
for _, op := range ops {
|
||||
txn.isWrite = txn.isWrite || op.isWrite()
|
||||
txn.fas = append(txn.fas, op.toRequestUnion())
|
||||
txn.fas = append(txn.fas, op.toRequestOp())
|
||||
}
|
||||
|
||||
return txn
|
||||
|
@ -128,11 +128,11 @@ func (s *simplePrinter) Txn(resp v3.TxnResponse) {
|
||||
for _, r := range resp.Responses {
|
||||
fmt.Println("")
|
||||
switch v := r.Response.(type) {
|
||||
case *pb.ResponseUnion_ResponseDeleteRange:
|
||||
case *pb.ResponseOp_ResponseDeleteRange:
|
||||
s.Del((v3.DeleteResponse)(*v.ResponseDeleteRange))
|
||||
case *pb.ResponseUnion_ResponsePut:
|
||||
case *pb.ResponseOp_ResponsePut:
|
||||
s.Put((v3.PutResponse)(*v.ResponsePut))
|
||||
case *pb.ResponseUnion_ResponseRange:
|
||||
case *pb.ResponseOp_ResponseRange:
|
||||
s.Get(((v3.GetResponse)(*v.ResponseRange)))
|
||||
default:
|
||||
fmt.Printf("unexpected response %+v\n", r)
|
||||
|
Loading…
x
Reference in New Issue
Block a user