From 3a6b72b858371017c9fb7ce003c456449d775fa6 Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Mon, 6 Jun 2016 12:16:33 -0700 Subject: [PATCH] add errNoAddr --- clientconn.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clientconn.go b/clientconn.go index e849da62..c38110da 100644 --- a/clientconn.go +++ b/clientconn.go @@ -71,6 +71,7 @@ var ( errConnDrain = errors.New("grpc: the connection is drained") // errConnClosing indicates that the connection is closing. errConnClosing = errors.New("grpc: the connection is closing") + errNoAddr = errors.New("grpc: there is no address available to dial") // minimum time to give a connection to complete minConnectTimeout = 20 * time.Second ) @@ -230,18 +231,18 @@ func Dial(target string, opts ...DialOption) (*ClientConn, error) { if err := cc.balancer.Start(target); err != nil { return nil, err } - ch := cc.balancer.Notify() var ( ok bool addrs []Address ) + ch := cc.balancer.Notify() if ch == nil { // There is no name resolver installed. addrs = append(addrs, Address{Addr: target}) } else { addrs, ok = <-ch if !ok || len(addrs) == 0 { - return nil, fmt.Errorf("grpc: there is no address available to dial") + return nil, errNoAddr } } waitC := make(chan error)