Skip to content
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

Make protoc-gen-grpc-gateway compatible with protoc-gen-go #503

Closed
ashi009 opened this issue Dec 14, 2017 · 2 comments
Closed

Make protoc-gen-grpc-gateway compatible with protoc-gen-go #503

ashi009 opened this issue Dec 14, 2017 · 2 comments

Comments

@ashi009
Copy link

ashi009 commented Dec 14, 2017

grpc-gen-go created a framework for writing protoc-gen-go plugins, instead of creating a protoc plugin, a protoc-gen-go plugin might be a better choice.

More specifically, gateway generator should implement github.com/golang/protobuf/protoc-gen-go/generator.Plugin interface. By doing this, it will help

  • avoiding all the boiler plates, as protoc-gen-go will handle them, and
  • making gateway generator easier to integrate with other protoc-gen-go plugins

In longer term, this will make it easier to integrate grpc-gateway with bazel/rules_go.

@achew22
Copy link
Collaborator

achew22 commented Dec 16, 2017

This sounds like a really interesting proposal. Beyond source compatibility with the protoc-gen-go plugin, can you help me understand what the specific benefits are?

  • avoiding all the boiler plates, as protoc-gen-go will handle them, and

We already have this boilerplate and it is tested pretty well. We currently handle most of these edge cases and have a fairly well tested codebase in that it is run in many organizations.

  • making gateway generator easier to integrate with other protoc-gen-go plugins

My understanding is that the composition of protoc generators is achieved by running the compiler multiple times and then using embed = [":proto", ":grpc", ":grpc_gateway"] in your rules_go go_library rule. Can you point me to some documentation that infers otherwise?

@ashi009
Copy link
Author

ashi009 commented Dec 21, 2017

I'll drop this FR in favor of #507, as now it has the same interface as the protoc-gen-go to execute. Running the compiler multiple times is fine with me. Though programmatically invoking these compilers is not completely smooth.

The boilerplates are the code handling imports, resolving types etc. Which is probably the most painful part for writing a protoc-gen plugin from scratch.

Also, go team has suggested that the protoc-gen-go plugin interface is designed for grpc alone, and they are not ready to make it a standard way for writing go proto compilers. I think at this point gogo has the best interface to work on for a simple protoc compiler.

@ashi009 ashi009 closed this as completed Dec 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants