Skip to content

Commit

Permalink
Merge pull request #8366 from heyitsanthony/prevkey-proxy
Browse files Browse the repository at this point in the history
grpcproxy: forward PrevKv flag in Put
  • Loading branch information
Anthony Romano authored Aug 4, 2017
2 parents faa4a62 + 6a4194c commit 366f538
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion integration/v3_grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestV3PutOverwrite(t *testing.T) {

kvc := toGRPC(clus.RandClient()).KV
key := []byte("foo")
reqput := &pb.PutRequest{Key: key, Value: []byte("bar")}
reqput := &pb.PutRequest{Key: key, Value: []byte("bar"), PrevKv: true}

respput, err := kvc.Put(context.TODO(), reqput)
if err != nil {
Expand All @@ -61,6 +61,9 @@ func TestV3PutOverwrite(t *testing.T) {
t.Fatalf("expected newer revision on overwrite, got %v <= %v",
respput2.Header.Revision, respput.Header.Revision)
}
if pkv := respput2.PrevKv; pkv == nil || string(pkv.Value) != "bar" {
t.Fatalf("expected PrevKv=bar, got response %+v", respput2)
}

reqrange := &pb.RangeRequest{Key: key}
resprange, err := kvc.Range(context.TODO(), reqrange)
Expand Down
3 changes: 3 additions & 0 deletions proxy/grpcproxy/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ func PutRequestToOp(r *pb.PutRequest) clientv3.Op {
if r.IgnoreLease {
opts = append(opts, clientv3.WithIgnoreLease())
}
if r.PrevKv {
opts = append(opts, clientv3.WithPrevKV())
}
return clientv3.OpPut(string(r.Key), string(r.Value), opts...)
}

Expand Down

0 comments on commit 366f538

Please sign in to comment.