aboutsummaryrefslogtreecommitdiff
path: root/weed/cluster/lock_client.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2023-06-25 19:31:25 -0700
committerchrislu <chris.lu@gmail.com>2023-06-25 19:31:25 -0700
commitaafb874ad2b4b39090ec644077df464c5b04f988 (patch)
tree7696068a37062bd12d297668f7be6ca723a4b1d0 /weed/cluster/lock_client.go
parentc4f44d56f795684b5c8b365abb5425b0559b8413 (diff)
downloadseaweedfs-aafb874ad2b4b39090ec644077df464c5b04f988.tar.xz
seaweedfs-aafb874ad2b4b39090ec644077df464c5b04f988.zip
lock until cancelled
Diffstat (limited to 'weed/cluster/lock_client.go')
-rw-r--r--weed/cluster/lock_client.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/weed/cluster/lock_client.go b/weed/cluster/lock_client.go
index 6a6f7a450..de37476a9 100644
--- a/weed/cluster/lock_client.go
+++ b/weed/cluster/lock_client.go
@@ -35,7 +35,17 @@ type LiveLock struct {
isLocked bool
}
-func (lc *LockClient) NewLock(filer pb.ServerAddress, key string, lockDuration time.Duration) (lock *LiveLock) {
+// NewLockWithTimeout locks the key with the given duration
+func (lc *LockClient) NewLockWithTimeout(filer pb.ServerAddress, key string, lockDuration time.Duration) (lock *LiveLock) {
+ return lc.doNewLock(filer, key, lockDuration)
+}
+
+// NewLock creates a lock with a very long duration
+func (lc *LockClient) NewLock(filer pb.ServerAddress, key string) (lock *LiveLock) {
+ return lc.doNewLock(filer, key, time.Duration(1<<63-1))
+}
+
+func (lc *LockClient) doNewLock(filer pb.ServerAddress, key string, lockDuration time.Duration) (lock *LiveLock) {
lock = &LiveLock{
key: key,
filer: filer,