Skip to content
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

Add dial option to set balancer #1697

Merged
merged 3 commits into from Dec 18, 2017
Merged

Conversation

menghanl
Copy link
Contributor

@menghanl menghanl commented Nov 28, 2017

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 Reviewable

@menghanl menghanl changed the title Add dial option to set balancer to initialize with Add dial option to set balancer Nov 28, 2017
@dfawley dfawley self-assigned this Nov 30, 2017
Copy link
Member

@dfawley dfawley left a 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.
Copy link
Member

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
Copy link
Member

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?

@menghanl menghanl force-pushed the with_balancer_name branch 3 times, most recently from 0480a85 to f379b65 Compare December 1, 2017 21:28
Copy link
Contributor Author

@menghanl menghanl left a 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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete, then LGTM.

@predmond
Copy link

Is this getting merged? I could use this feature..

@menghanl menghanl force-pushed the with_balancer_name branch 2 times, most recently from 1b7bf44 to bedcbb9 Compare December 12, 2017 22:31
@@ -670,9 +678,9 @@ func (cc *ClientConn) handleResolvedAddrs(addrs []resolver.Address, err error) {

cc.curAddresses = addrs

Copy link
Contributor Author

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
And make WithBalancerName panic if no balancer is registered
@menghanl menghanl merged commit e6549e6 into grpc:master Dec 18, 2017
@menghanl menghanl deleted the with_balancer_name branch December 18, 2017 23:35
@dfawley dfawley added this to the 1.9 Release milestone Jan 2, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants