diff --git a/clientconn.go b/clientconn.go index 4abfc32a..040ca830 100644 --- a/clientconn.go +++ b/clientconn.go @@ -68,7 +68,7 @@ var ( // ErrNetworkIP indicates that the connection is down due to some network I/O error. ErrNetworkIO = errors.New("grpc: failed with network I/O error") // ErrConnDrain indicates that the connection starts to be drained and does not accept any new RPCs. - ErrConnDrain = errors.New("grpc: ") + ErrConnDrain = errors.New("grpc: the connection is drained") errConnClosing = errors.New("grpc: the addrConn is closing") // minimum time to give a connection to complete minConnectTimeout = 20 * time.Second @@ -121,6 +121,13 @@ func WithNameResolver(r naming.Resolver) DialOption { } } +// WithBalancer returns a DialOption which sets a load balancer. +func WithBalancer(b Balancer) DialOption { + return func(o *dialOptions) { + o.balancer = b + } +} + // WithBackoffMaxDelay configures the dialer to use the provided maximum delay // when backing off after failed connection attempts. func WithBackoffMaxDelay(md time.Duration) DialOption { @@ -471,20 +478,6 @@ type addrConn struct { transport transport.ClientTransport } -/* -func (ac *addrConn) startDrain() { - ac.mu.Lock() - t := ac.transport - ac.drain = true - if ac.down != nil { - ac.down(ErrConnDrain) - ac.down = nil - } - ac.mu.Unlock() - ac.tearDown(ErrConnDrain) -} -*/ - // printf records an event in ac's event log, unless ac has been closed. // REQUIRES ac.mu is held. func (ac *addrConn) printf(format string, a ...interface{}) {