Is it possible to make GRPC_OP_RECV_MESSAGE optional on client side

33 views
Skip to first unread message

Ram

unread,
Jul 22, 2020, 1:50:31 PM7/22/20
to grpc.io
Team gRPC,

We've a scenario where a gRPC client sets up all the operations and does a grpc_call_start_batch(), something like this:

https://github.com/grpc/grpc/blob/master/test/core/end2end/tests/trailing_metadata.cc#L153
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 2;
....
<snip>
......
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
op->reserved = nullptr;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op->flags = 0;
op->reserved = nullptr;
op++;
....
<snip>
......
error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
nullptr);

GPR_ASSERT(GRPC_CALL_OK == error);

In some scenarios, the server side sends only initial metadata whereas in some other scenarios it sends a message as well along with initial metadata and the client isn't aware of when one vs the other scenario happens.

Is it possible to wake up client (i.e., event posted on the completion queue) to respond to both scenarios? I tried digging around in test subdir, couldn't find my scenario https://github.com/grpc/grpc/tree/master/test 

Any pointers or alternative options on this will be of help, thank you!

Best, -Ram.


Ram

unread,
Jul 24, 2020, 1:59:46 PM7/24/20
to grpc.io
Any comments on the feasibility of this or other options to explore? Thank you.

Michael Lumish

unread,
Jul 24, 2020, 2:30:53 PM7/24/20
to Ram, grpc.io
The simplest way to handle this is to put the GRPC_OP_RECV_MESSAGE into a separate batch. You can wait for the batch with the metadata, then wait for the message batch. If the server ends the call without sending a message, the message batch will end with a null message.

--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/6688642d-3807-4f94-995c-174b985281e8n%40googlegroups.com.

Sivaram Kumar Battu

unread,
Jul 24, 2020, 8:49:58 PM7/24/20
to Michael Lumish, grpc.io
Thank you Michael, will check if we can restructure the client to handle GRPC_OP_RECV_MESSAGE into a separate batch.

Best, -Ram.
Reply all
Reply to author
Forward
0 new messages