Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we use gRPC with Flatbuffers?

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.

like image 827
GawdePrasad Avatar asked Dec 09 '15 04:12

GawdePrasad


2 Answers

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.

like image 152
Aardappel Avatar answered Oct 17 '22 14:10

Aardappel


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.

like image 9
Eric Anderson Avatar answered Oct 17 '22 16:10

Eric Anderson