浏览代码

Allow client to set boltdb timeout

- also in case of no persistent connection

Signed-off-by: Alessandro Boch <aboch@docker.com>
Alessandro Boch 8 年之前
父节点
当前提交
6c0e0d6250
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      libnetwork/internal/kvstore/boltdb/boltdb.go

+ 6 - 1
libnetwork/internal/kvstore/boltdb/boltdb.go

@@ -59,6 +59,7 @@ func New(endpoints []string, options *store.Config) (store.Store, error) {
 		db          *bolt.DB
 		err         error
 		boltOptions *bolt.Options
+		timeout     = transientTimeout
 	)
 
 	if len(endpoints) > 1 {
@@ -82,11 +83,15 @@ func New(endpoints []string, options *store.Config) (store.Store, error) {
 		}
 	}
 
+	if options.ConnectionTimeout != 0 {
+		timeout = options.ConnectionTimeout
+	}
+
 	b := &BoltDB{
 		client:            db,
 		path:              endpoints[0],
 		boltBucket:        []byte(options.Bucket),
-		timeout:           transientTimeout,
+		timeout:           timeout,
 		PersistConnection: options.PersistConnection,
 	}