1. use github.com/coreos instead of go.etcd.io in etcd related import path; 2. add dialtimeout to etcd client

This commit is contained in:
outshow
2019-06-11 16:18:37 +08:00
parent 46de3ae9a9
commit 90a9df9b8c
5 changed files with 27 additions and 8 deletions

View File

@@ -6,9 +6,9 @@ import (
"net"
"time"
cetcd "github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/mvcc/mvccpb"
"github.com/micro/go-micro/config/source"
cetcd "go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/mvcc/mvccpb"
)
// Currently a single etcd reader
@@ -100,8 +100,15 @@ func NewSource(opts ...source.Option) source.Source {
endpoints = []string{"localhost:2379"}
}
// check dial timeout option
dialTimeout, ok := options.Context.Value(dialTimeoutKey{}).(time.Duration)
if !ok {
dialTimeout = 3 * time.Second // default dial timeout
}
config := cetcd.Config{
Endpoints: endpoints,
Endpoints: endpoints,
DialTimeout: dialTimeout,
}
u, ok := options.Context.Value(authKey{}).(*authCreds)