-
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
Support service definitions without any annotations. #1649
Comments
Hi Philippe, thanks for raising this issue! I had a read through the My initial reaction to this was that it isn't been requested before and so I don't know how useful this is to users, at the same time I believe users are making use of the feature that allows you to select which endpoints to expose, so with that in mind, if this was something we couldn't still offer to users, I think I'd be inclined to say no. However, you make a fair argument and I think we could get the best of both worlds with a generator parameter that can be toggled on and off. We could even consider changing the default of such a parameter for v2 if it proved uncontroversial. I do like the idea of being able to just run the generator on an existing or third-party proto file and generating a transcoding server. So I'm tentatively going to accept this proposal, behind a flag for v1 and v2 for now, and I'd be happy to discuss changing the default behavior in v2 after some testing, and if we are given the time before we tag v2.0.0. This feature would not block a v2 release as we can introduce it in a backwards compatible manner. What do you need from me to start implementing this? |
@johanbrandhorst Great! thanks for the quick reply and considering this addition. I'll take a look around the codebase (v1 and v2) and see if any questions come up. The first thing that comes to mind is naming. Do you have any opinions on how to name this flag/parameter? Given that there's a |
Great, lets start painting this bike shed before we get to deep into the implementation 😂. I think for v1 we'll want a switch that's off by default, and we probably want the naming to reflect that. I like On that note, I wonder if this new feature should affect the behavior of that use case. I expect it probably should, so that's something to keep in mind. If we set Does that make sense? |
@johanbrandhorst I took a quick stab at this for the gateway generator; see #1652 In this version, the interaction between the new option and WDYT? |
* Adds generate_unbound_methods parameter. This will also warn the user when they use the new option with the existing `warn_on_unbound_methods` * Handle generate unbound methods option. This adds the necessary code to handle the new `generate_unbound_methods` option. The strategy used is to generate default options when the service method has no option and the flag is enabled. It also adds a simple test. * Adds reference to gRPC HTTP/2 mapping. * Adds similar option to gen-swagger. * Adds example for generate_unbounud_methods parameter. * Adds resulting generated examples. * Adds missing bazel build updates. * Adds missing BUILD file. * Simplify .gitignore files. * TIDY: fixup comments. * Update generated files with new comments. * Adds documentation for generate_unbound_methods parameter. * Adds documentation for generate_unbound_methods to README. * Apply suggestions from code review `protoc` invocation example cleanup Co-authored-by: Johan Brandhorst-Satzkorn <[email protected]> * Some markdown tidyness, additional protoc invocation documentation. Co-authored-by: Johan Brandhorst-Satzkorn <[email protected]> Fixes #1649
🚀 Feature
When a service definition does not use any REST / transcoding annotations, it should still be possible to generate a gateway and OpenAPI spec by using the default gRPC path.
As per the gRPC spec, the path of a particular operation is well-defined:
/<service name>/<method name>
. Moreover, the request and response are serialized in the body and there's no use of any request parameter or header to pass information around. Lastly, the HTTP verb is also well-defined:POST
.Thus, there's a clear default to use when a service has no api annotation. In fact, this is what "Cloud Endpoint" does https://cloud.google.com/endpoints/docs/grpc/transcoding#where_to_configure_transcoding
This would be useful because:
This is probably a breaking change since users can no longer "selectively" pick the rpc methods to expose in the gateway. That said, having the default behaviour be exposing all methods instead of none of them seems less surprising. Furthermore, users can have separate service definitions or perhaps additional annotations could be used to "turn off" gateway generation per method.
Could such a feature be considered for v2?
The text was updated successfully, but these errors were encountered: