-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
option to tweak generated Register* function names #571
option to tweak generated Register* function names #571
Conversation
@achew22, are you the right person to ping if I'm hoping to get a change reviewed? |
Ping @achew22? |
Looking at this, I don't think this is a change that I would be comfortable making. This would be a breaking change for every single user of the project in search of compatibility that I don't think is widely needed. If this becomes a community standard and part of every major gRPC installation (or gets rolled into go-grpc-core) then I would definitely be receptive to making this change. If I may ask a higher level question. Given that there is a collision on that name right now, it seems likely there will be more collisions. Do you intend to run down every other project who is potentially going to conflict on that generated name? Maybe it would be a good idea to switch your handler to If this is a change that you think absolutely must be implemented, I think that making this a configurable flag in the generator followed by a slow migration and a major version upgrade hard cutover is the way to go. I will warn you that the bar for testing it at an acceptable level will be really high and will involve probably duplicating all of this projects integration tests to ensure that we don't break anyone in either configuration. Sorry to not give a happy, "let's merge this", but I have concerns WRT major breaking changes like this. |
How so? It behaves exactly as it does today unless requested via plugin arg.
That's what I've done.
I would not expect you to accept a breaking change. Please take a longer look at the PR description and code. |
PIng @achew22. If you don't mind reviewing. This is not a breaking change. Please take a closer look at the PR description and the code. |
I just got a bit of time to actually look at the code (sorry for firing back so fast, things have been really crazy of late). For the most part I'm okay with this. I would like to see something added in the examples folder that has the flag changed so we can ensure that the handler is properly renamed in all the cases it needs to be by actually compiling it. You should be able to do that in the |
dc9f1f5
to
ae6fda2
Compare
@achew22, I rebased this. I'm trying to figure out how to actually do what you requested, regarding a test that the option is working. Am I correct to be staring at Bazel build files? I don't see any existing examples/tests that exercise the other options. Maybe I am looking in the wrong place. A little more direction appreciated. |
The build breakage was bad timing - I pushed just after protobuf merged their dev branch to master. I will rebase this PR after #636 lands, to see if I can get the tests to go green. |
ae6fda2
to
d54e528
Compare
Codecov Report
@@ Coverage Diff @@
## master #571 +/- ##
==========================================
+ Coverage 58.88% 58.88% +<.01%
==========================================
Files 30 30
Lines 2853 2863 +10
==========================================
+ Hits 1680 1686 +6
- Misses 1010 1014 +4
Partials 163 163
Continue to review full report at Codecov.
|
ping @achew22 |
We have our own protoc plugin that wants to generate a
Register<ServiceName>Handler
function: https://godoc.org/github.com/fullstorydev/grpchanIf I use both the grpchan and grpc-gateway protoc plugins, they generate code that won't compile. I would really prefer the grpc-gateway functions be named
Register<ServiceName>HTTPHandler
to make the distinction more obvious from the name.So this pull request provides an option that can be used to change the generated name. The option is
register-func-suffix
and it defaults"Handler"
to preserve the names if the option is not used.I can then do this in my own go:generate directive to get the desired output: