clientv3: add no endpoint error

This commit is contained in:
Xiang Li 2016-02-02 11:01:58 -08:00
parent 87ed04ea6f
commit 7a91108b91

View File

@ -15,6 +15,7 @@
package clientv3
import (
"errors"
"net"
"net/url"
"sync"
@ -27,6 +28,10 @@ import (
"github.com/coreos/etcd/pkg/transport"
)
var (
ErrNoAvailableEndpoints = errors.New("etcdclient: no available endpoints")
)
// Client provides and manages an etcd v3 client session.
type Client struct {
// KV is the keyvalue API for the client's connection.
@ -67,6 +72,10 @@ func New(cfg Config) (*Client, error) {
if cfg.RetryDialer == nil {
cfg.RetryDialer = dialEndpointList
}
if len(cfg.Endpoints) == 0 {
return nil, ErrNoAvailableEndpoints
}
return newClient(&cfg)
}