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

balancer: support hierarchical paths in addresses #3494

Merged
merged 5 commits into from
Apr 16, 2020

Conversation

menghanl
Copy link
Contributor

@menghanl menghanl commented Apr 2, 2020

internal/hierarchy.Group()

@menghanl menghanl requested review from easwars and dfawley April 2, 2020 18:19
@menghanl menghanl added the Type: Feature New features or improvements in behavior label Apr 2, 2020
@menghanl menghanl added this to the 1.29 Release milestone Apr 2, 2020
@easwars easwars modified the milestones: 1.29 Release, 1.30 Release Apr 8, 2020
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.

A few suggestions for function names. Should this go into its own package?

balancer/base/hierarchical.go Outdated Show resolved Hide resolved
balancer/base/hierarchical.go Outdated Show resolved Hide resolved
balancer/base/hierarchical.go Outdated Show resolved Hide resolved
@dfawley dfawley assigned menghanl and unassigned easwars and dfawley Apr 15, 2020
@menghanl menghanl assigned dfawley and unassigned menghanl Apr 15, 2020
*/

// Package hierarchy contains functions to set and get hierarchy string from
// addresses.
Copy link
Member

Choose a reason for hiding this comment

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

// Experimental

(or in an internal directory)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did both.

Moved to internal.
Does this even belong to balancer? This is modifying resolver.Address, and can be set by a resolver. We need a bar package.


// Package hierarchy contains functions to set and get hierarchy string from
// addresses.
package hierarchy
Copy link
Member

Choose a reason for hiding this comment

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

Does this package logically belong under base? I feel like it's its own thing under balancer, but not strongly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See the other comment. Maybe not even balancer?

balancer/base/hierarchy/hierarchy.go Outdated Show resolved Hide resolved
}

// Set overrides the hierarchical path in addr with path.
func Set(addr resolver.Address, path []string) resolver.Address {
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about accepting a pointer and modifing in place?

Copy link
Contributor Author

@menghanl menghanl Apr 16, 2020

Choose a reason for hiding this comment

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

Copying is cleaner to use?

// Copy
for _, addr := range addrs {
    newAddrs = append(newAddrs, Set(addr, ["a","b"]))
}

// Update
for _, addr := range addrs {
    // Hmm, is the local variable `addr` already a copy?
    Set(&addr, ["a","b"])
    newAddrs = append(newAddrs, addr)
}

// With update, or even do everything in place?
for i, addr := range addrs {
    // Does this work?? addr is a copy?
    Set(&addr, ["a","b"]

    // Does this work?
    Set(&(addrs[i]), ["a","b"])
}

Another question is, what should Group() do? Should it modify the passed in addresses, or copy?

balancer/base/hierarchy/hierarchy.go Outdated Show resolved Hide resolved
@dfawley dfawley assigned menghanl and unassigned dfawley Apr 16, 2020
@menghanl menghanl merged commit 759569b into grpc:master Apr 16, 2020
@menghanl menghanl deleted the balancer_hierarchy branch April 16, 2020 21:45
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants