-
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
grpc: do not use balancer attributes during address comparison #6439
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,10 @@ type StubServer struct { | |
Address string | ||
Target string | ||
|
||
// Custom listener to use for serving. If unspecified, a new listener is | ||
// created on a local port. | ||
Listener net.Listener | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a parameter for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My code search reveals that nobody is setting
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do the cleanup in a follow up PR. Thanks. |
||
|
||
cleanups []func() // Lambdas executed in Stop(); populated by Start(). | ||
|
||
// Set automatically if Target == "" | ||
|
@@ -118,9 +122,13 @@ func (ss *StubServer) StartServer(sopts ...grpc.ServerOption) error { | |
ss.R = manual.NewBuilderWithScheme("whatever") | ||
} | ||
|
||
lis, err := net.Listen(ss.Network, ss.Address) | ||
if err != nil { | ||
return fmt.Errorf("net.Listen(%q, %q) = %v", ss.Network, ss.Address, err) | ||
lis := ss.Listener | ||
if lis == nil { | ||
var err error | ||
lis, err = net.Listen(ss.Network, ss.Address) | ||
if err != nil { | ||
return fmt.Errorf("net.Listen(%q, %q) = %v", ss.Network, ss.Address, err) | ||
} | ||
} | ||
ss.Address = lis.Addr().String() | ||
ss.cleanups = append(ss.cleanups, func() { lis.Close() }) | ||
|
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.
This one doesn't print literal quotes.
Why not keep it the way it was? Have this return the actual string and quote it when it's used?
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.
Yeah, makes sense.