From 550765d03780d069503822e75317bd0e43fc9ede Mon Sep 17 00:00:00 2001 From: James Shubin Date: Fri, 1 Sep 2017 13:33:31 -0400 Subject: [PATCH] clientv3: Add LeaseValue helper to Cmp LeaseID values in Txn --- clientv3/compare.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clientv3/compare.go b/clientv3/compare.go index 18131e8b4cb..9bab55c59c2 100644 --- a/clientv3/compare.go +++ b/clientv3/compare.go @@ -84,6 +84,12 @@ func ModRevision(key string) Cmp { 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. func (cmp *Cmp) KeyBytes() []byte { return cmp.Key }