-
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
grpc: optional interface to provide channel authority #6752
Conversation
Also implements the same for unix resolver's builder
Codecov Report
Additional details and impacted files |
hi @dfawley, I have a couple queries:
Should we mention the same in our comments?
I guess we could add a line in the comments for |
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.
Thank you for the PR! A few comments inline...
clientconn.go
Outdated
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Please delete the TODO below.
clientconn.go
Outdated
@@ -1981,16 +1981,14 @@ func (cc *ClientConn) determineAuthority() error { | |||
} | |||
|
|||
endpoint := cc.parsedTarget.Endpoint() | |||
target := cc.target | |||
auth, isAuthOverrider := any(cc.resolverBuilder).(resolver.AuthorityOverrider) |
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 type
thanks
resolver/resolver.go
Outdated
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. | ||
GetServiceAuthority(t Target) string |
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.
Go style generally doesn't like GetXYZ
. OverrideAuthority
makes more sense given the name of the interface; otherwise AuthorityForTarget
or something like that could be okay.
resolver/resolver.go
Outdated
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. | ||
GetServiceAuthority(t Target) string |
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.
Please name the parameter target
to be explicit, or don't name it at all, as t
doesn't really add documentation value here, and it's not necessary to name.
clientconn.go
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: maybe just convert this into a few if
s and do the auth overrider as a compound if
.
@dfawley thank you for the review, I have pushed the review changes to the PR |
This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
clientconn.go
Outdated
case isAuthOverrider: | ||
cc.authority = auth.GetServiceAuthority(cc.parsedTarget) | ||
case strings.HasPrefix(endpoint, ":"): | ||
} else if auth, isAuthOverrider := cc.resolverBuilder.(resolver.AuthorityOverrider); isAuthOverrider { |
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.
Go style: please name this ok
instead of isAuthOverrider
.
internal/resolver/unix/unix.go
Outdated
@@ -61,6 +61,10 @@ func (b *builder) Scheme() string { | |||
return b.scheme | |||
} | |||
|
|||
func (b *builder) OverrideAuthority(t resolver.Target) string { |
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.
Since t
is unused, you can omit it entirely here.
+@arvindbr8 for a second pass |
This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
hi @arvindbr8, could you please review the PR and remove the reporter clarification status? |
@Aditya-Sood : Thank you for your contribution! |
Also implements the same for unix resolver's builder
Fixes #5360
RELEASE NOTES: