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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
reflection: accept interface instead of grpc.Server struct in Register() #4340
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could we do something like this instead?
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.
@dfawley, this is more or less what I proposed earlier: #4340 (comment)
I will push a commit to this branch that makes that change.
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.
Done. I've pushed two commits.
The first one implements what you suggest above. The downside to this is that it is not strictly backwards compatible, due to the signature change for
Register
.However, it has been done in past releases of this module, such as migrating things (particularly generated code) to require a
grpc.ClientConnInterface
orgrpc.ServiceRegistrar
instead of the concrete types*grpc.ClientConn
and*grpc.Server
.So maybe it's okay? What do you think?
The second commit I just pushed actually makes further changes (and changes some names, in the hopes of making the API more coherent) that are strictly backwards compatible.
If you prefer the first formulation, I can rollback that last commit. Let me know.
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.
Of the two, I prefer the former. The only affected users would be ones referring to the function by its type, and I see little reason to this. Plus it keeps the API as minimal as possible. Using an interface is mildly worrying, since it means we can't extend it in the future, but we can do type assertions (to other interfaces) or introduce a new API if we ever do need to add features. Thanks for the PR & revisions.
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.
Okay, SGTM. I removed that last commit to take it back to the simpler form. Anything else you'd like to see, or do you think this one is good to go?