@@ -8,25 +8,25 @@ import (
8
8
"github.com/monetha/go-distributed/locker"
9
9
)
10
10
11
- // consulLocker wraps Consul distributed lock by implementing Locker interface.
12
- type consulLocker struct {
11
+ // Locker wraps Consul distributed lock by implementing Locker interface.
12
+ type Locker struct {
13
13
client * api.Client
14
14
key string
15
15
lockWaitTime time.Duration
16
16
lock * api.Lock
17
17
}
18
18
19
- // NewConsulLocker creates new consulLocker instance.
20
- func newConsulLocker (client * api.Client , key string , lockWaitTime time.Duration ) * consulLocker {
21
- return & consulLocker {
19
+ // NewLocker creates new Locker instance.
20
+ func NewLocker (client * api.Client , key string , lockWaitTime time.Duration ) * Locker {
21
+ return & Locker {
22
22
client : client ,
23
23
key : key ,
24
24
lockWaitTime : lockWaitTime ,
25
25
}
26
26
}
27
27
28
28
// Key returns the name of locker.
29
- func (l * consulLocker ) Key () string {
29
+ func (l * Locker ) Key () string {
30
30
return l .key
31
31
}
32
32
@@ -37,7 +37,7 @@ func (l *consulLocker) Key() string {
37
37
// communication errors, operator intervention, etc. It is NOT safe to
38
38
// assume that the locker is held until Unlock(), application must be able
39
39
// to handle the locker being lost.
40
- func (l * consulLocker ) Lock (stopCh <- chan struct {}) (<- chan struct {}, error ) {
40
+ func (l * Locker ) Lock (stopCh <- chan struct {}) (<- chan struct {}, error ) {
41
41
if l .lock != nil {
42
42
return nil , locker .ErrLockHeld
43
43
}
@@ -66,7 +66,7 @@ func (l *consulLocker) Lock(stopCh <-chan struct{}) (<-chan struct{}, error) {
66
66
67
67
// Unlock released the locker. It is an error to call this
68
68
// if the locker is not currently held.
69
- func (l * consulLocker ) Unlock () error {
69
+ func (l * Locker ) Unlock () error {
70
70
if l .lock == nil {
71
71
return locker .ErrLockNotHeld
72
72
}
0 commit comments