Remove 'lockSuffix' as not needed in 'etcd' v3.

This commit is contained in:
Bruno Miguel Custodio 2017-09-08 16:59:39 +01:00
parent bb4dec6032
commit 038f5eb638
No known key found for this signature in database
GPG Key ID: 84CDD9E18A1A6B2C
2 changed files with 2 additions and 5 deletions

View File

@ -18,7 +18,6 @@ import (
const ( const (
lockAcquireTimeout = 2 * time.Second lockAcquireTimeout = 2 * time.Second
lockInfoSuffix = ".lockinfo" lockInfoSuffix = ".lockinfo"
lockSuffix = ".lock"
) )
// RemoteClient is a remote client that will store data in etcd. // RemoteClient is a remote client that will store data in etcd.
@ -165,7 +164,7 @@ func (c *RemoteClient) lock() (string, error) {
ctx, cancel := context.WithTimeout(context.TODO(), lockAcquireTimeout) ctx, cancel := context.WithTimeout(context.TODO(), lockAcquireTimeout)
defer cancel() defer cancel()
mutex := etcdv3sync.NewMutex(session, c.Key+lockSuffix) mutex := etcdv3sync.NewMutex(session, c.Key)
if err1 := mutex.Lock(ctx); err1 != nil { if err1 := mutex.Lock(ctx); err1 != nil {
lockInfo, err2 := c.getLockInfo() lockInfo, err2 := c.getLockInfo()
if err2 != nil { if err2 != nil {

View File

@ -83,13 +83,11 @@ func TestEtcdv3_destroyLock(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
lockPath := c.Key + lockSuffix
if err := c.Unlock(id); err != nil { if err := c.Unlock(id); err != nil {
t.Fatal(err) t.Fatal(err)
} }
res, err := c.Client.KV.Get(context.TODO(), lockPath) res, err := c.Client.KV.Get(context.TODO(), c.Key)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }