On Wednesday, August 17, 2022 at 3:02:55 PM UTC-7 cruise...@gmail.com wrote:

> Is there an example of how to use a gRPC client/server with just a buffer
> payload? The closest answer I've seen so far is that it requires a
> protobuf message with a bytes field

Serialization is controlled by specializations of SerializationTraits [1].
There is a built-in one for the grpc::ByteBuffer type [2].

So, using something like grpc::ServerAsyncResponseWriter<grpc::ByteBuffer>
or grpc::ServerWriteReactor<grpc::ByteBuffer> should already work if you can
use grpc::ByteBuffer as your buffer type.

Note: the ProtoBuf codegen writes a lot of the glue code to register
"handler" code for the various methods that you want to expose. If you want
to use raw byte buffers, you'll need to write this code yourself. It's been
a while since I looked at what protoc generates. I'd start by running
codegen on the helloworld.proto file and looking at what it emits for the
the Greeter::AsyncService and Greeter::CallbackService base classes.

I've also not used the callback/reactor model in C++, only the
"async"/completion queue model. I _assume_ the callback/reactor model uses
SerializationTraits as well.

[1]: https://grpc.github.io/grpc/cpp/classgrpc_1_1_serialization_traits.html
[2]: 
https://grpc.github.io/grpc/cpp/classgrpc_1_1_serialization_traits_3_01_byte_buffer_00_01void_01_4.html
 


-- 
Christopher Warrington
Microsoft Corp.

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/fa9e6715-2839-44c6-a30c-7ef0931f25a2n%40googlegroups.com.

Reply via email to