-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Conversation
balancer/base.SplitHierarchicalAddresses
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.
A few suggestions for function names. Should this go into its own package?
balancer/base/hierarchy/hierarchy.go
Outdated
*/ | ||
|
||
// Package hierarchy contains functions to set and get hierarchy string from | ||
// addresses. |
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.
// Experimental
(or in an internal directory)
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.
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.
balancer/base/hierarchy/hierarchy.go
Outdated
|
||
// Package hierarchy contains functions to set and get hierarchy string from | ||
// addresses. | ||
package hierarchy |
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.
Does this package logically belong under base
? I feel like it's its own thing under balancer
, but not strongly.
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.
See the other comment. Maybe not even balancer
?
balancer/base/hierarchy/hierarchy.go
Outdated
} | ||
|
||
// Set overrides the hierarchical path in addr with path. | ||
func Set(addr resolver.Address, path []string) resolver.Address { |
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.
What do you think about accepting a pointer and modifing in place?
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.
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?
internal/hierarchy.Group()