clientv3: let client.Dial() dial endpoints not in the balancer

release-3.2
Anthony Romano 2017-04-12 17:53:18 -07:00
parent 2046d66927
commit 9b8e39e7ca
1 changed files with 6 additions and 1 deletions

View File

@ -219,6 +219,11 @@ func (c *Client) dialSetupOpts(endpoint string, dopts ...grpc.DialOption) (opts
f := func(host string, t time.Duration) (net.Conn, error) {
proto, host, _ := parseEndpoint(c.balancer.getEndpoint(host))
if host == "" && endpoint != "" {
// dialing an endpoint not in the balancer; use
// endpoint passed into dial
proto, host, _ = parseEndpoint(endpoint)
}
if proto == "" {
return nil, fmt.Errorf("unknown scheme for %q", host)
}
@ -358,7 +363,7 @@ func newClient(cfg *Config) (*Client, error) {
}
client.balancer = newSimpleBalancer(cfg.Endpoints)
conn, err := client.dial(cfg.Endpoints[0], grpc.WithBalancer(client.balancer))
conn, err := client.dial("", grpc.WithBalancer(client.balancer))
if err != nil {
client.cancel()
client.balancer.Close()