|
@@ -52,6 +52,9 @@ type Op struct {
|
|
|
// for watch, put, delete
|
|
// for watch, put, delete
|
|
|
prevKV bool
|
|
prevKV bool
|
|
|
|
|
|
|
|
|
|
+ // for put
|
|
|
|
|
+ ignoreValue bool
|
|
|
|
|
+
|
|
|
// progressNotify is for progress updates.
|
|
// progressNotify is for progress updates.
|
|
|
progressNotify bool
|
|
progressNotify bool
|
|
|
// createdNotify is for created event
|
|
// createdNotify is for created event
|
|
@@ -94,7 +97,7 @@ func (op Op) toRequestOp() *pb.RequestOp {
|
|
|
case tRange:
|
|
case tRange:
|
|
|
return &pb.RequestOp{Request: &pb.RequestOp_RequestRange{RequestRange: op.toRangeRequest()}}
|
|
return &pb.RequestOp{Request: &pb.RequestOp_RequestRange{RequestRange: op.toRangeRequest()}}
|
|
|
case tPut:
|
|
case tPut:
|
|
|
- r := &pb.PutRequest{Key: op.key, Value: op.val, Lease: int64(op.leaseID), PrevKv: op.prevKV}
|
|
|
|
|
|
|
+ r := &pb.PutRequest{Key: op.key, Value: op.val, Lease: int64(op.leaseID), PrevKv: op.prevKV, IgnoreValue: op.ignoreValue}
|
|
|
return &pb.RequestOp{Request: &pb.RequestOp_RequestPut{RequestPut: r}}
|
|
return &pb.RequestOp{Request: &pb.RequestOp_RequestPut{RequestPut: r}}
|
|
|
case tDeleteRange:
|
|
case tDeleteRange:
|
|
|
r := &pb.DeleteRangeRequest{Key: op.key, RangeEnd: op.end, PrevKv: op.prevKV}
|
|
r := &pb.DeleteRangeRequest{Key: op.key, RangeEnd: op.end, PrevKv: op.prevKV}
|
|
@@ -360,6 +363,15 @@ func WithPrevKV() OpOption {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// WithIgnoreValue updates the key using its current value.
|
|
|
|
|
+// Empty value should be passed when ignore_value is set.
|
|
|
|
|
+// Returns an error if the key does not exist.
|
|
|
|
|
+func WithIgnoreValue() OpOption {
|
|
|
|
|
+ return func(op *Op) {
|
|
|
|
|
+ op.ignoreValue = true
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// LeaseOp represents an Operation that lease can execute.
|
|
// LeaseOp represents an Operation that lease can execute.
|
|
|
type LeaseOp struct {
|
|
type LeaseOp struct {
|
|
|
id LeaseID
|
|
id LeaseID
|