19

I have been studying about Apache Thrift, ProtoBuf and Flatbuffers. I found the tutorial to use gRPC with protobuf at link but I am not finding any documentation to use gRPC with Flatbuffers. Can some one point me to the relevant documentation? I checked it on Google as well as on Stackoverflow. Any help would be appreciated.

GawdePrasad
  • 623
  • 1
  • 7
  • 15

3 Answers3

16

Since this question was first asked, progress has been made in a) making GRPC codegen independent of protobuf (see https://github.com/grpc/grpc/pull/6130) and then to integrate that codegenerator in the flatbuffers compiler flatc: https://github.com/google/flatbuffers/commit/48f37f9e0a04f2b60046dda7fef20a8b0ebc1a70

This is a a very basic first implementation, feedback welcome.

Aardappel
  • 5,559
  • 1
  • 19
  • 22
  • 4
    This is pretty exciting! – Bklyn Jul 29 '16 at 01:54
  • @Aardappel I think there is some issue with `--grpc` can you please check this out: https://stackoverflow.com/questions/64063320/flatbuffers-when-grpc-is-used-error-no-template-named-streamedunaryhandler – Venelin Sep 25 '20 at 12:22
10

The gRPC protocol is payload-agnostic, but the code generation is not. Since there isn't code generation already for FlatBuffers you will need to do some things manually.

The details vary by language, but the basic pieces are similar. As an example, in Go you would need to implement Codec and prepare the descriptors necessary for Invoke, NewClientStream, and RegisterService. In Java you would need to implement Marshaller and prepare the descriptors necessary for newCall and addService. If you have trouble, you may consider looking at the generated code for gRPC when used with Protobuf.

Eric Anderson
  • 24,057
  • 5
  • 55
  • 76
  • 7
    While it is in theory agnostic, in practice it is not set up well for things that are not protobuf. This could all be a lot easier. Please prod the gPRC maintainers to improve support for naked buffers, or directly support FlatBuffers. – Aardappel Dec 09 '15 at 18:24
  • It could be easier in general, or it could be easier for FlatBuffers in particular? – Eric Anderson Dec 09 '15 at 20:47
  • For FlatBuffers or any other serialization system that is not protobuf. – Aardappel Dec 10 '15 at 02:10
  • The IDL and codegen do need to vary reasonably with different serializers. Improving support for particular serializers is easier than arbitrary serializers. I do believe we are open to concrete suggestions for improvements that could be made. – Eric Anderson Dec 10 '15 at 18:49
  • Yeah, any suggestions to make it a lot easier are very welcome! – jcanizales Dec 14 '15 at 20:44
4

Since 2017-08-17 gRPC has out-of-the-box support for flatbuffers as mentioned in their blog https://grpc.io/blog/grpc-flatbuffers/#use-flatbuffers-as-an-idl

The recent release of Flatbuffers version 1.7 introduced truly zero-copy support for gRPC out of the box.

Example command from the linked article

flatc --cpp --grpc example.fbs
Can Rau
  • 3,130
  • 1
  • 23
  • 33