-
Notifications
You must be signed in to change notification settings - Fork 836
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
[WIP] Add grpc-web support #207
Conversation
This looks very useful 🎉 I am not familiar with grpc web, I have the following questions.
|
6c7288b
to
13cbca4
Compare
13cbca4
to
8ac23f4
Compare
Some docs on how to add Protobuf message converter could be useful, such as for when a message has a property of the Any type. I have this if you need a contribution. |
This is a really interesting feature- it could be a good alternative for replacing a custom REST API alternative to a gRPC API. Are there specific caveats that should be known? I had also been looking at Go based solutions that can code-gen a web proxy from the gRPC “reflection” metadata endpoint, but likely would need to wrap that in a container of some kind for external configuration and reuse across services. I’ve started reviewing but will likely take a bit longer later this week to fully grok and give decent feedback. |
I already wrote some
IIRC Streaming calls are currently not supported and I'm not sure how to implement them. I also have to consider other libraries in this area such as grpc-gateway for compatibility reasons.
Thanks, but your effort might end up in vain, because I thought about rewritting the code from scratch to support thinks like custom curls that are defined in the protobuf files.
Thanks you very much for the feedback. This is a very big feature and it didn't gather any attention, so my motivation to pushing this forward was low. If you think this is worthwhile, perhaps we can revive it. |
I do think it’s worth exploring. Would it be packaged as a separate module? Regarding streaming, I believe that web sockets is the best fit on the HTTP/2 side. This is even bigger to tackle, but could prove to be pretty interesting. Both of these features may be more desirable separated from Spring, then wrapped up for Spring here. (Similar to things like Micrometer usage in Actuator.) Have you considered that sort of set up? I might be willing to contribute to this more actively. |
If you consider
If we use HTTP/2 we could just use grpc. It should be possible to support HTTP1 as well. Or are websockets always HTTP2?
I haven't thought about that yet.
|
What about google.api.http support? |
Yeah, support for those is planned, but I never had the time to fully implement it. |
FWIW, we're using grpc-spring-boot-starter for gRPC services and leverage Ambassador to handle the grpc-web encoding. These are server-streaming APIs and are long-lived. IIRC, client-streaming isn't officially supported yet (though there was an improbable grpc-web websocket proxy but it was labeled as not ready for production). |
8ac23f4
to
e121b3a
Compare
Very interesting functionality. Сould you share information, in what state is it at the moment? Is there any implementation plan? |
Due to time constraints I haven't looked into it. I still haven't searched/found a way to register the web request mappings dynamically.
The implementation is currently not scheduled for a specific release. Contributions are welcome. |
Do I understand correctly that the problem is to dynamically determine by the REST input address which service and method should be called, while they are already in the context of the spring? If I understood the problem correctly, could this be a possible solution? @RequestMapping(value = "/grpc/{service}/{method}", method = RequestMethod.POST)
public void restRouter(@PathVariable("service") String service, @PathVariable("method") String method, @RequestBody Object body) {
//Then load bean from context by service value and call method by method value?
} |
Well, part of it. |
I want to express my gratitude for the idea and explanation. Now I seem to understand what the problem exactly is with dynamic REST mapping. |
Thanks for the hint. I originally intended the PojoFormat to allow "any Content-Type" to be translated into a "pojo"/map using spring's |
Any progress? |
Unfortunately not. I currently don't have time to tackle this. |
Sounds like an interesting approach, I'm not sure whether I can interweave this with normal spring-web. Might be worth a try. |
I suppose you need to collect all the grpc mappings and register Serlvet only for them.
|
This is now mostly obsolete due to: grpc/grpc-java#8596 |
Work in progress - Feedback appreciated
Adds #196
Usage simply add
grpc-spring-boot-starter-web
to your dependencies and the library will automatically provide web methods to access the grpc-services.Calls
GET /grpc
Lists all available grpc-methods
POST /grpc/{service}/{method}
Execute the given grpc-method with the data that were send in the request body.
If you want to send multiple requests (client streaming) you can do so by sending a list of inputs (json-array).
Features
HttpMessageConverter
if you want to add additional formatsTODO