Browse Source

Merge pull request #8488 from purpleidea/feat/leaseid-helper

clientv3: Add LeaseValue helper to Cmp LeaseID values in Txn
Xiang Li 8 years ago
parent
commit
b1595f2792
1 changed files with 6 additions and 0 deletions
  1. 6 0
      clientv3/compare.go

+ 6 - 0
clientv3/compare.go

@@ -84,6 +84,12 @@ func ModRevision(key string) Cmp {
 	return Cmp{Key: []byte(key), Target: pb.Compare_MOD}
 	return Cmp{Key: []byte(key), Target: pb.Compare_MOD}
 }
 }
 
 
+// LeaseValue compares a key's LeaseID to a value of your choosing. The empty
+// LeaseID is 0, otherwise known as `NoLease`.
+func LeaseValue(key string) Cmp {
+	return Cmp{Key: []byte(key), Target: pb.Compare_LEASE}
+}
+
 // KeyBytes returns the byte slice holding with the comparison key.
 // KeyBytes returns the byte slice holding with the comparison key.
 func (cmp *Cmp) KeyBytes() []byte { return cmp.Key }
 func (cmp *Cmp) KeyBytes() []byte { return cmp.Key }