Merge pull request #4848 from heyitsanthony/rename-compare-created

clientv3: rename comparison from CreatedRevision to CreateRevision
This commit is contained in:
Anthony Romano 2016-03-23 10:32:49 -07:00
commit ca5dff6682
5 changed files with 5 additions and 5 deletions

View File

@ -72,7 +72,7 @@ func Version(key string) Cmp {
return Cmp{Key: []byte(key), Target: pb.Compare_VERSION} return Cmp{Key: []byte(key), Target: pb.Compare_VERSION}
} }
func CreatedRevision(key string) Cmp { func CreateRevision(key string) Cmp {
return Cmp{Key: []byte(key), Target: pb.Compare_CREATE} return Cmp{Key: []byte(key), Target: pb.Compare_CREATE}
} }

View File

@ -74,7 +74,7 @@ func (e *Election) Proclaim(ctx context.Context, val string) error {
if e.leaderSession == nil { if e.leaderSession == nil {
return ErrElectionNotLeader return ErrElectionNotLeader
} }
cmp := v3.Compare(v3.CreatedRevision(e.leaderKey), "=", e.leaderRev) cmp := v3.Compare(v3.CreateRevision(e.leaderKey), "=", e.leaderRev)
txn := e.client.Txn(ctx).If(cmp) txn := e.client.Txn(ctx).If(cmp)
txn = txn.Then(v3.OpPut(e.leaderKey, val, v3.WithLease(e.leaderSession.Lease()))) txn = txn.Then(v3.OpPut(e.leaderKey, val, v3.WithLease(e.leaderSession.Lease())))
tresp, terr := txn.Commit() tresp, terr := txn.Commit()

View File

@ -64,7 +64,7 @@ func (m *Mutex) Unlock() error {
} }
func (m *Mutex) IsOwner() v3.Cmp { func (m *Mutex) IsOwner() v3.Cmp {
return v3.Compare(v3.CreatedRevision(m.myKey), "=", m.myRev) return v3.Compare(v3.CreateRevision(m.myKey), "=", m.myRev)
} }
func (m *Mutex) Key() string { return m.myKey } func (m *Mutex) Key() string { return m.myKey }

View File

@ -33,7 +33,7 @@ func TestTxnPanics(t *testing.T) {
} }
} }
cmp := Compare(CreatedRevision("foo"), "=", 0) cmp := Compare(CreateRevision("foo"), "=", 0)
op := OpPut("foo", "bar") op := OpPut("foo", "bar")
tests := []struct { tests := []struct {

View File

@ -183,7 +183,7 @@ func parseCompare(line string) (*clientv3.Cmp, error) {
} }
case "c", "create": case "c", "create":
if v, err = strconv.ParseInt(val, 10, 64); err == nil { if v, err = strconv.ParseInt(val, 10, 64); err == nil {
cmp = clientv3.Compare(clientv3.CreatedRevision(key), op, v) cmp = clientv3.Compare(clientv3.CreateRevision(key), op, v)
} }
case "m", "mod": case "m", "mod":
if v, err = strconv.ParseInt(val, 10, 64); err == nil { if v, err = strconv.ParseInt(val, 10, 64); err == nil {