Skip to content

Commit

Permalink
clientv3: return ErrNoAvailableEndpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed Feb 2, 2016
1 parent e220b77 commit 0ef001a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions clientv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package clientv3

import (
"errors"
"sync"
"time"

Expand All @@ -25,6 +26,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.
Expand Down Expand Up @@ -182,6 +187,10 @@ func (c *Client) retryConnection(oldConn *grpc.ClientConn, err error) (*grpc.Cli
// connection is established.
func dialEndpointList(c *Client) (*grpc.ClientConn, error) {
var err error
if len(c.Endpoints()) == 0 {
return nil, ErrNoAvailableEndpoints
}

for _, ep := range c.Endpoints() {
conn, curErr := c.Dial(ep)
if curErr != nil {
Expand Down

0 comments on commit 0ef001a

Please sign in to comment.