-
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: optional interface to provide channel authority #6752
Changes from 2 commits
eab9b33
5cc6bab
fa15301
b6617ec
1dd2231
fb65458
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 |
---|---|---|
|
@@ -1981,16 +1981,14 @@ func (cc *ClientConn) determineAuthority() error { | |
} | ||
|
||
endpoint := cc.parsedTarget.Endpoint() | ||
target := cc.target | ||
auth, isAuthOverrider := any(cc.resolverBuilder).(resolver.AuthorityOverrider) | ||
switch { | ||
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. Optional: maybe just convert this into a few |
||
case authorityFromDialOption != "": | ||
cc.authority = authorityFromDialOption | ||
case authorityFromCreds != "": | ||
cc.authority = authorityFromCreds | ||
case strings.HasPrefix(target, "unix:") || strings.HasPrefix(target, "unix-abstract:"): | ||
// TODO: remove when the unix resolver implements optional interface to | ||
// return channel authority. | ||
cc.authority = "localhost" | ||
case isAuthOverrider: | ||
cc.authority = auth.GetServiceAuthority(cc.parsedTarget) | ||
case strings.HasPrefix(endpoint, ":"): | ||
cc.authority = "localhost" + endpoint | ||
default: | ||
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. Please delete the TODO below. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,3 +319,12 @@ type Resolver interface { | |
// Close closes the resolver. | ||
Close() | ||
} | ||
|
||
// AuthorityOverrider is implemented by Builders that wish to override the | ||
// default authority for the ClientConn. | ||
// By default, the authority used is target.Endpoint() | ||
easwars marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type AuthorityOverrider interface { | ||
// GetServiceAuthority returns the authority to use for a ClientConn with the | ||
// given target. It must not perform I/O or any other blocking operations. | ||
easwars marked this conversation as resolved.
Show resolved
Hide resolved
|
||
GetServiceAuthority(t Target) string | ||
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. Go style generally doesn't like 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. Please name the parameter |
||
} |
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.
Why cast it to
any
first? That shouldn't be needed.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.
my bad,
cc.resolverBuilder
is already an interface typethanks