-
Notifications
You must be signed in to change notification settings - Fork 38.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 Protobuf serialization in WebFlux [SPR-15776] #20331
Comments
Sébastien Deleuze commented Greg Laubenstein Protobuf, even in GRPC, seems mainly based on |
Greg Laubenstein commented I believe: https://github.com/zeroc-ice has a generated async API. |
Vitaly Romashkin commented Hi, guys. And what about Thrift RPC? Is it possible to make integration async Thrift RPC with Webflux? Created additional feature request - #21011 |
Rossen Stoyanchev commented Indeed the gRPC Marshaller uses
Then I looked for some media types to indicate protobuf streming with the length-delimited format, and found a couple examples:
There doesn't seem to be a standard but we can look around some more and pick something. After all supported media types are easy to customize. For the implementation, some useful notes here led me to MessageLite#mergeFrom which checks the size and returns true or false depending on whether it has read the full message or not. We probably still have to do extra work to buffer data chunks until a full message is parsed, but that hopefully not too bad. Using "protobuf" and "delimited" as keywords, there may be more insight or examples out there for all of the above, but it seems we have enough here to give it a try. |
Rossen Stoyanchev commented Scheduling tentatively for 5.1 RC1 to give this a try. |
Rossen Stoyanchev commented I've updated the title a bit, since I think this ticket is about Protobuf (de)serialization over HTTP, not as part of gRPC. Let me know if I've misunderstood, but in any case we have a separate ticket (#20905) for gRPC. |
Sébastien Deleuze commented Rossen Stoyanchev Arjen Poutsma Brian Clozel I have worked on a draft commit implementing such support. Streams are expected to use delimited Protobuf messages with the size of each message specified before the message itself as suggested by Rossen. Single values are expected to use regular Protobuf message format (without the size prepended before the message). In addition to battle test stream decoding, here is the list of open questions I have identified:
Thanks in advance for your feedback. |
Piotr Dudkiewicz commented Sébastien Deleuze, thanks for draft commit, I've adapted it in my project and it works well. I've found one issue though - when service returns default instance of protobuf message (which is serialized to an empty byte array by protobuf), WebClient decodes it to an empty Mono, not to Mono with default instance as I would expect (like gRPC does). |
Sébastien Deleuze commented Piotr Dudkiewicz Reading https://developers.google.com/protocol-buffers/docs/proto3#default and thinking about |
Piotr Dudkiewicz commented Indeed there is no way to differentiate. If webmvc version of protobuf decoder works the same way |
Sébastien Deleuze commented An improved version of Protobuf support will be available in Spring Framework 5.1 RC2, see this commit for more detail. |
Greg Laubenstein opened SPR-15776 and commented
Currently there is no built in means to serialize and deserialize data objects with RPC/protobuf with reactive-web/webflux.
Affects: 5.0.4
Issue Links:
@MVC
: Add support for google Protocol Buffers resource representation formatReferenced from: commits 3899b7a, 36bbbab, 36a07aa, 6b6384a
4 votes, 13 watchers
The text was updated successfully, but these errors were encountered: