mirror of https://github.com/milvus-io/milvus.git
enhance: Add `WithBlock` option for etcd client creation (#32641)
Related to #32598 Use `WithBlock` may fail fast when create etcd client to some invalid etcd endpoints and make it easier to check problem. Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/32664/head
parent
2ab57ca10c
commit
967cfb3133
|
@ -28,6 +28,7 @@ import (
|
|||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
"go.etcd.io/etcd/server/v3/embed"
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/milvus-io/milvus/pkg/log"
|
||||
)
|
||||
|
@ -64,6 +65,9 @@ func GetRemoteEtcdClient(endpoints []string) (*clientv3.Client, error) {
|
|||
return clientv3.New(clientv3.Config{
|
||||
Endpoints: endpoints,
|
||||
DialTimeout: 5 * time.Second,
|
||||
DialOptions: []grpc.DialOption{
|
||||
grpc.WithBlock(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -73,6 +77,9 @@ func GetRemoteEtcdClientWithAuth(endpoints []string, userName, password string)
|
|||
DialTimeout: 5 * time.Second,
|
||||
Username: userName,
|
||||
Password: password,
|
||||
DialOptions: []grpc.DialOption{
|
||||
grpc.WithBlock(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -119,6 +126,8 @@ func GetRemoteEtcdSSLClientWithCfg(endpoints []string, certFile string, keyFile
|
|||
return nil, errors.Errorf("unknown TLS version,%s", minVersion)
|
||||
}
|
||||
|
||||
cfg.DialOptions = append(cfg.DialOptions, grpc.WithBlock())
|
||||
|
||||
return clientv3.New(cfg)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue