Remove 'lockSuffix' as not needed in 'etcd' v3.
This commit is contained in:
parent
bb4dec6032
commit
038f5eb638
|
@ -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 {
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue