Add dial option to set balancer#1697
Conversation
dfawley
left a comment
There was a problem hiding this comment.
Since we're giving users a way of specifying balancers by name, we should also provide a way of doing this programmatically vs. manually using strings.
I.e. we should add roundrobin.Name and grpc.PickFirstBalancerName constants.
| // WithBalancer returns a DialOption which sets a load balancer with the v1 API. | ||
| // Name resolver will be ignored if this DialOption is specified. | ||
| // Deprecated: use the new balancer APIs in balancer package instead. | ||
| // Deprecated: use the new balancer APIs in balancer package and WithBalancerName. |
There was a problem hiding this comment.
Nit: add a blank comment line above this one so it's its own paragraph.
clientconn.go
Outdated
| } | ||
|
|
||
| // WithBalancerName sets the balancer that the ClientConn will be initialized | ||
| // with. The balancer can not be overridden by balancer option specified by |
There was a problem hiding this comment.
Nit: "cannot" or "will not".
Also, maybe something like: "Balancers are registered by name using the balancer package" before this sentence?
0480a85 to
f379b65
Compare
menghanl
left a comment
There was a problem hiding this comment.
Thanks for the review. All done. PTAL.
clientconn.go
Outdated
| // withBalancerBuilder is for testing only. Users using custom balancers should | ||
| // register their balancer and use service config to choose the balancer to use. | ||
| func WithBalancerBuilder(b balancer.Builder) DialOption { | ||
| func withBalancerBuilder(b balancer.Builder) DialOption { |
a04906e to
c24621d
Compare
|
Is this getting merged? I could use this feature.. |
1b7bf44 to
bedcbb9
Compare
| @@ -670,9 +678,9 @@ func (cc *ClientConn) handleResolvedAddrs(addrs []resolver.Address, err error) { | |||
|
|
|||
| cc.curAddresses = addrs | |||
|
|
|||
There was a problem hiding this comment.
@dfawley I updated the following if else while doing a rebase. Please take another look. Thanks!
service config will not override dial option balancer fix comments Add const roundrobin.Name and PickFirstBalancerName. remove WithBalancerBuilder fix tests delete withBalancerBuilder
343e6c5 to
e488e4c
Compare
And make WithBalancerName panic if no balancer is registered
WithBalancerName dial option specifies the name of the balancer to be used by the ClientConn. Service config updates can NOT override the balancer option.
#1694
This change is