浏览代码

Migration to the new Etcd client

This commit migrates the old 'go-etcd' client, which is deprecated
to the new 'coreos/etcd/client'.

One notable change is the ability to specify an 'IsDir' parameter
to the 'Put' call. This allows to circumvent the limitations of etcd
regarding the key/directory distinction while setting up Watches on
a directory. A conservative measure to set up a watch that should be
used the same way for etcd/consul/zookeeper is to enforce the 'IsDir'
parameter with 'WriteOptions' on 'Put' to avoid the 'NotANode' error
thrown by etcd on Watch call. Consul and zookeeper are not using the
'IsDir' parameter.

Signed-off-by: Alexandre Beslic <abronan@docker.com>
Alexandre Beslic 9 年之前
父节点
当前提交
2603af65e5
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      libnetwork/internal/kvstore/kvstore.go

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

@@ -46,7 +46,7 @@ type Config struct {
 }
 }
 
 
 // ClientTLSConfig contains data for a Client TLS configuration in the form
 // ClientTLSConfig contains data for a Client TLS configuration in the form
-//  the etcd client wants it.  Eventually we'll adapt it for ZK and Consul.
+// the etcd client wants it.  Eventually we'll adapt it for ZK and Consul.
 type ClientTLSConfig struct {
 type ClientTLSConfig struct {
 	CertFile   string
 	CertFile   string
 	KeyFile    string
 	KeyFile    string
@@ -108,7 +108,8 @@ type KVPair struct {
 
 
 // WriteOptions contains optional request parameters
 // WriteOptions contains optional request parameters
 type WriteOptions struct {
 type WriteOptions struct {
-	TTL time.Duration
+	IsDir bool
+	TTL   time.Duration
 }
 }
 
 
 // LockOptions contains optional request parameters
 // LockOptions contains optional request parameters