-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add dial option to set balancer #1697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
clientconn.go
Outdated
@@ -188,7 +190,7 @@ func WithDecompressor(dc Decompressor) DialOption { | |||
|
|||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: add a blank comment line above this one so it's its own paragraph.
clientconn.go
Outdated
@@ -206,6 +208,15 @@ func WithBalancerBuilder(b balancer.Builder) DialOption { | |||
} | |||
} | |||
|
|||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. All done. PTAL.
clientconn.go
Outdated
// 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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete, then LGTM.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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