瀏覽代碼

Merge pull request #63 from abronan/consul_ttl_lock

Add TTL to Consul lock using store.LockOptions
Victor Vieux 10 年之前
父節點
當前提交
3c89e44f3e
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      libnetwork/internal/kvstore/kvstore.go

+ 4 - 3
libnetwork/internal/kvstore/kvstore.go

@@ -113,13 +113,14 @@ type WriteOptions struct {
 
 
 // LockOptions contains optional request parameters
 // LockOptions contains optional request parameters
 type LockOptions struct {
 type LockOptions struct {
-	Value []byte        // Optional, value to associate with the lock
-	TTL   time.Duration // Optional, expiration ttl associated with the lock
+	Value     []byte        // Optional, value to associate with the lock
+	TTL       time.Duration // Optional, expiration ttl associated with the lock
+	RenewLock chan struct{} // Optional, chan used to control and stop the session ttl renewal for the lock
 }
 }
 
 
 // Locker provides locking mechanism on top of the store.
 // Locker provides locking mechanism on top of the store.
 // Similar to `sync.Lock` except it may return errors.
 // Similar to `sync.Lock` except it may return errors.
 type Locker interface {
 type Locker interface {
-	Lock() (<-chan struct{}, error)
+	Lock(stopChan chan struct{}) (<-chan struct{}, error)
 	Unlock() error
 	Unlock() error
 }
 }