ClientBidiReactor or ClientCallbackReaderWriter

128 views
Skip to first unread message

Christopher Pisz

unread,
Nov 4, 2020, 4:49:30 PM11/4/20
to grpc.io
I see these classes mentioned in the grpc "docs", but I do not see how to get yourself an instance of them when making an RPC call. How do you get one? Can I indeed be called back when reads or writes complete? That would suit me much better than the ClientReaderWriter interface.

Donna Dionne

unread,
Nov 13, 2020, 1:02:13 PM11/13/20
to grpc.io
You can just create an instance like this:

class TestClientBidiReactor : public ClientBidiReactor<TestRequest, TestResponse> {
public:
  explicit TestClientBidiReactor(Stub* stub, ClientContext& context, ...) { ...}

There is StartRead and StartWrite
StartCall will activate the call (so use after Read and Write)

You can implement OnReadDone, OnWriteDone, and/or OnDone to achieve the callback behaviour you need.

ClientCallBackReadWrite you can also create; just watch out that the streaming objects are not actually implemented in the public API.  A reactor is usually used!





Christopher Pisz

unread,
Dec 16, 2020, 7:01:56 PM12/16/20
to grpc.io
For some reason, despite my including `/grpc/support/client_callback.h` my compiler doesn't know what ::grpc::ClientCallbackBidiReactor or any other class starting with ClientCallback, is. is there some define you need to get these to show up?
Reply all
Reply to author
Forward
0 new messages