34 #ifndef GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H
35 #define GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H
114 virtual bool Read(R* msg) = 0;
187 call_(channel->CreateCall(method, context, &cq_)) {
191 ops.SendInitialMetadata(context->send_initial_metadata_,
192 context->initial_metadata_flags());
195 ops.ClientSendClose();
211 ops.RecvInitialMetadata(context_);
228 if (!context_->initial_metadata_received_) {
229 ops.RecvInitialMetadata(context_);
231 ops.RecvMessage(msg);
233 return cq_.Pluck(&ops) && ops.got_message;
244 ops.ClientRecvStatus(context_, &status);
288 call_(channel->CreateCall(method, context, &cq_)) {
289 finish_ops_.RecvMessage(response);
290 finish_ops_.AllowNoMessage();
292 if (!context_->initial_metadata_corked_) {
294 ops.SendInitialMetadata(context->send_initial_metadata_,
295 context->initial_metadata_flags());
311 ops.RecvInitialMetadata(context_);
324 CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
330 ops.ClientSendClose();
332 if (context_->initial_metadata_corked_) {
333 ops.SendInitialMetadata(context_->send_initial_metadata_,
334 context_->initial_metadata_flags());
337 if (!ops.SendMessage(msg, options).ok()) {
342 return cq_.Pluck(&ops);
347 ops.ClientSendClose();
349 return cq_.Pluck(&ops);
360 if (!context_->initial_metadata_received_) {
361 finish_ops_.RecvInitialMetadata(context_);
363 finish_ops_.ClientRecvStatus(context_, &status);
381 template <
class W,
class R>
405 template <
class W,
class R>
417 call_(channel->CreateCall(method, context, &cq_)) {
418 if (!context_->initial_metadata_corked_) {
420 ops.SendInitialMetadata(context->send_initial_metadata_,
421 context->initial_metadata_flags());
437 ops.RecvInitialMetadata(context_);
453 if (!context_->initial_metadata_received_) {
454 ops.RecvInitialMetadata(context_);
456 ops.RecvMessage(msg);
458 return cq_.Pluck(&ops) && ops.got_message;
468 CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
474 ops.ClientSendClose();
476 if (context_->initial_metadata_corked_) {
477 ops.SendInitialMetadata(context_->send_initial_metadata_,
478 context_->initial_metadata_flags());
481 if (!ops.SendMessage(msg, options).ok()) {
486 return cq_.Pluck(&ops);
491 ops.ClientSendClose();
493 return cq_.Pluck(&ops);
503 if (!context_->initial_metadata_received_) {
504 ops.RecvInitialMetadata(context_);
507 ops.ClientRecvStatus(context_, &status);
539 ops.SendInitialMetadata(ctx_->initial_metadata_,
540 ctx_->initial_metadata_flags());
544 ctx_->sent_initial_metadata_ =
true;
546 call_->
cq()->Pluck(&ops);
556 ops.RecvMessage(msg);
558 return call_->
cq()->Pluck(&ops) && ops.got_message;
587 ops.SendInitialMetadata(ctx_->initial_metadata_,
588 ctx_->initial_metadata_flags());
592 ctx_->sent_initial_metadata_ =
true;
594 call_->
cq()->Pluck(&ops);
608 if (!ops.SendMessage(msg, options).ok()) {
611 if (!ctx_->sent_initial_metadata_) {
612 ops.SendInitialMetadata(ctx_->initial_metadata_,
613 ctx_->initial_metadata_flags());
617 ctx_->sent_initial_metadata_ =
true;
620 return call_->
cq()->Pluck(&ops);
629 template <
class W,
class R>
636 template <
class W,
class R>
637 class ServerReaderWriterBody final {
640 : call_(call), ctx_(ctx) {}
646 ops.SendInitialMetadata(ctx_->initial_metadata_,
647 ctx_->initial_metadata_flags());
651 ctx_->sent_initial_metadata_ =
true;
653 call_->
cq()->Pluck(&ops);
663 ops.RecvMessage(msg);
665 return call_->
cq()->Pluck(&ops) && ops.got_message;
673 if (!ops.SendMessage(msg, options).ok()) {
676 if (!ctx_->sent_initial_metadata_) {
677 ops.SendInitialMetadata(ctx_->initial_metadata_,
678 ctx_->initial_metadata_flags());
682 ctx_->sent_initial_metadata_ =
true;
685 return call_->
cq()->Pluck(&ops);
698 template <
class W,
class R>
709 return body_.NextMessageSize(sz);
712 bool Read(R* msg)
override {
return body_.Read(msg); }
721 return body_.Write(msg, options);
736 template <
class RequestType,
class ResponseType>
741 : body_(call, ctx), read_done_(false), write_done_(false) {}
764 bool Read(RequestType* request)
override {
769 return body_.
Read(request);
781 if (write_done_ || !read_done_) {
785 return body_.
Write(response, options);
799 template <
class RequestType,
class ResponseType>
804 : body_(call, ctx), read_done_(false) {}
827 bool Read(RequestType* request)
override {
832 return body_.
Read(request);
844 return read_done_ && body_.
Write(response, options);
854 #endif // GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: channel_interface.h:49
Client-side interface for streaming writes of message type W.
Definition: sync_stream.h:258
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context.h:184
WriteOptions & set_buffer_hint()
Sets flag indicating that the write may be buffered and need not go out on the wire immediately...
Definition: call.h:136
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream.h:712
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
Common interface for all synchronous server side streaming.
Definition: sync_stream.h:81
bool Write(const W &msg, WriteOptions options)
Definition: sync_stream.h:668
Server-side interface for bi-directional streaming.
Definition: sync_stream.h:630
A class to represent a flow-controlled server-side streaming call.
Definition: sync_stream.h:800
ServerReaderWriterBody(Call *call, ServerContext *ctx)
Definition: sync_stream.h:639
bool NextMessageSize(uint32_t *sz)
Definition: sync_stream.h:656
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:442
Client-side interface for streaming reads of message of type R.
Definition: sync_stream.h:161
Definition: completion_queue.h:73
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call.h:175
virtual ~ServerStreamingInterface()
Definition: sync_stream.h:83
An interface that yields a sequence of messages of type R.
Definition: sync_stream.h:96
bool Write(const ResponseType &response, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:780
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:137
A class to represent a flow-controlled unary call.
Definition: sync_stream.h:737
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:226
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:535
virtual ~ReaderInterface()
Definition: sync_stream.h:98
void set_initial_metadata_corked(bool corked)
Flag whether the initial metadata should be corked.
Definition: client_context.h:315
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:810
bool Read(R *msg)
Definition: sync_stream.h:661
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:601
Server-side interface for streaming reads of message of type R.
Definition: sync_stream.h:521
Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:241
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream.h:554
bool Write(const ResponseType &response, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:843
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream.h:345
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:451
Definition: grpc_types.h:602
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:168
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:68
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:216
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:467
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream.h:813
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:706
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:708
void SendInitialMetadata()
Definition: sync_stream.h:642
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:583
ServerReader(Call *call, ServerContext *ctx)
Definition: sync_stream.h:530
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream.h:750
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:764
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:720
Events are popped out by calling grpc_completion_queue_pluck() API ONLY.
Definition: grpc_types.h:598
virtual ~ClientStreamingInterface()
Definition: sync_stream.h:51
Server-side interface for streaming writes of message of type W.
Definition: sync_stream.h:568
virtual bool NextMessageSize(uint32_t *sz)=0
Get an upper bound on the next message size available for reading on this stream. ...
ClientReader(ChannelInterface *channel, const RpcMethod &method, ClientContext *context, const W &request)
Block to create a stream and write the initial metadata and request out.
Definition: sync_stream.h:181
CompletionQueue * cq() const
Definition: call.h:659
int max_receive_message_size() const
Definition: call.h:661
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:603
Straightforward wrapping of the C call object.
Definition: call.h:638
virtual bool WritesDone()=0
Half close writing from the client.
Codegen interface for grpc::Channel.
Definition: channel_interface.h:64
virtual bool Write(const W &msg, WriteOptions options)=0
Block to write msg to the stream with WriteOptions options.
virtual void SendInitialMetadata()=0
Block to send initial metadata to client.
The completion queue will have an associated pollset and there is no restriction on the type of file ...
Definition: grpc_types.h:578
Primary implementaiton of CallOpSetInterface.
Definition: call.h:583
Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:358
A ServerContext allows the person implementing a service handler to:
Definition: server_context.h:109
ServerSplitStreamer(Call *call, ServerContext *ctx)
Definition: sync_stream.h:803
Per-message write options.
Definition: call.h:96
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:747
ClientReaderWriter(ChannelInterface *channel, const RpcMethod &method, ClientContext *context)
Block to create a stream and write the initial metadata and request out.
Definition: sync_stream.h:411
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:549
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
virtual bool WritesDone()=0
Half close writing from the client.
bool Write(const W &msg)
Block to write msg to the stream with default write options.
Definition: sync_stream.h:138
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs, where the outgoing message stream coming from the server has messages of type W.
Definition: completion_queue.h:70
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:101
ServerUnaryStreamer(Call *call, ServerContext *ctx)
Definition: sync_stream.h:740
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream.h:489
Descriptor of an RPC method.
Definition: rpc_method.h:44
Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:501
virtual Status Finish()=0
Block waiting until the stream finishes and a final status of the call is available.
void WaitForInitialMetadata() override
Block waiting to read initial metadata from the server.
Definition: sync_stream.h:433
ServerReaderWriter(Call *call, ServerContext *ctx)
Definition: sync_stream.h:701
Synchronous (blocking) server-side API for a bidirectional streaming call, where the incoming message...
Definition: sync_stream.h:699
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:654
An interface that can be fed a sequence of messages of type W.
Definition: sync_stream.h:119
Client-side interface for bi-directional streaming with client-to-server stream messages of type W an...
Definition: sync_stream.h:382
Did it work? If it didn't, why?
Definition: status.h:45
void WaitForInitialMetadata() override
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:207
virtual bool Read(R *msg)=0
Block to read a message and parse to msg.
Common interface for all synchronous client side streaming.
Definition: sync_stream.h:49
ServerWriter(Call *call, ServerContext *ctx)
Definition: sync_stream.h:577
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:827
void WriteLast(const W &msg, WriteOptions options)
Write msg and coalesce it with the writing of trailing metadata, using WriteOptions options...
Definition: sync_stream.h:154
void WaitForInitialMetadata()
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:307
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: channel_interface.h:53
bool compression_level_set() const
Return a bool indicating whether the compression level for this call has been set (either implicitly ...
Definition: server_context.h:199
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: channel_interface.h:51
ClientWriter(ChannelInterface *channel, const RpcMethod &method, ClientContext *context, R *response)
Block to create a stream (i.e.
Definition: sync_stream.h:282
bool is_last_message() const
Get value for the flag indicating that this is the last message, and should be coalesced with trailin...
Definition: call.h:191
virtual ~WriterInterface()
Definition: sync_stream.h:121
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:323