18 #ifndef GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H 19 #define GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H 76 virtual void SendInitialMetadata() = 0;
87 virtual bool NextMessageSize(uint32_t* sz) = 0;
99 virtual bool Read(R* msg) = 0;
155 virtual void WaitForInitialMetadata() = 0;
164 const ::grpc::internal::RpcMethod& method,
190 ops.RecvInitialMetadata(context_);
191 call_.PerformOps(&ops);
196 *sz = call_.max_receive_message_size();
209 if (!context_->initial_metadata_received_) {
210 ops.RecvInitialMetadata(context_);
213 call_.PerformOps(&ops);
214 return cq_.Pluck(&ops) && ops.got_message;
225 ops.ClientRecvStatus(context_, &status);
226 call_.PerformOps(&ops);
242 const ::grpc::internal::RpcMethod& method,
248 call_(channel->CreateCall(method, context, &cq_)) {
253 ops.SendInitialMetadata(&context->send_initial_metadata_,
254 context->initial_metadata_flags());
257 ops.ClientSendClose();
274 virtual bool WritesDone() = 0;
283 const ::grpc::internal::RpcMethod& method,
308 ops.RecvInitialMetadata(context_);
322 ::grpc::internal::CallOpSendMessage,
328 ops.ClientSendClose();
330 if (context_->initial_metadata_corked_) {
331 ops.SendInitialMetadata(&context_->send_initial_metadata_,
332 context_->initial_metadata_flags());
333 context_->set_initial_metadata_corked(
false);
335 if (!ops.SendMessagePtr(&msg, options).ok()) {
340 return cq_.Pluck(&ops);
345 ops.ClientSendClose();
347 return cq_.Pluck(&ops);
358 if (!context_->initial_metadata_received_) {
359 finish_ops_.RecvInitialMetadata(context_);
361 finish_ops_.ClientRecvStatus(context_, &status);
377 const ::grpc::internal::RpcMethod& method,
383 call_(channel->CreateCall(method, context, &cq_)) {
384 finish_ops_.RecvMessage(response);
385 finish_ops_.AllowNoMessage();
387 if (!context_->initial_metadata_corked_) {
390 ops.SendInitialMetadata(&context->send_initial_metadata_,
391 context->initial_metadata_flags());
409 template <
class W,
class R>
418 virtual void WaitForInitialMetadata() = 0;
426 virtual bool WritesDone() = 0;
430 template <
class W,
class R>
435 const ::grpc::internal::RpcMethod& method,
446 template <
class W,
class R>
460 ops.RecvInitialMetadata(context_);
478 if (!context_->initial_metadata_received_) {
479 ops.RecvInitialMetadata(context_);
481 ops.RecvMessage(msg);
483 return cq_.Pluck(&ops) && ops.got_message;
494 ::grpc::internal::CallOpSendMessage,
500 ops.ClientSendClose();
502 if (context_->initial_metadata_corked_) {
503 ops.SendInitialMetadata(&context_->send_initial_metadata_,
504 context_->initial_metadata_flags());
505 context_->set_initial_metadata_corked(
false);
507 if (!ops.SendMessagePtr(&msg, options).ok()) {
512 return cq_.Pluck(&ops);
517 ops.ClientSendClose();
519 return cq_.Pluck(&ops);
531 if (!context_->initial_metadata_received_) {
532 ops.RecvInitialMetadata(context_);
535 ops.ClientRecvStatus(context_, &status);
552 const ::grpc::internal::RpcMethod& method,
558 call_(channel->CreateCall(method, context, &cq_)) {
559 if (!context_->initial_metadata_corked_) {
562 ops.SendInitialMetadata(&context->send_initial_metadata_,
563 context->initial_metadata_flags());
589 ops.SendInitialMetadata(&ctx_->initial_metadata_,
590 ctx_->initial_metadata_flags());
591 if (ctx_->compression_level_set()) {
592 ops.set_compression_level(ctx_->compression_level());
594 ctx_->sent_initial_metadata_ =
true;
596 call_->
cq()->Pluck(&ops);
606 ops.RecvMessage(msg);
608 return call_->
cq()->Pluck(&ops) && ops.got_message;
615 template <
class ServiceType,
class RequestType,
class ResponseType>
616 friend class ::grpc::internal::ClientStreamingHandler;
619 : call_(call), ctx_(ctx) {}
642 ops.SendInitialMetadata(&ctx_->initial_metadata_,
643 ctx_->initial_metadata_flags());
644 if (ctx_->compression_level_set()) {
645 ops.set_compression_level(ctx_->compression_level());
647 ctx_->sent_initial_metadata_ =
true;
649 call_->
cq()->Pluck(&ops);
663 if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
666 if (!ctx_->sent_initial_metadata_) {
667 ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
668 ctx_->initial_metadata_flags());
669 if (ctx_->compression_level_set()) {
670 ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
672 ctx_->sent_initial_metadata_ =
true;
679 ctx_->has_pending_ops_ =
true;
682 ctx_->has_pending_ops_ =
false;
683 return call_->
cq()->Pluck(&ctx_->pending_ops_);
690 template <
class ServiceType,
class RequestType,
class ResponseType>
691 friend class ::grpc::internal::ServerStreamingHandler;
694 : call_(call), ctx_(ctx) {}
698 template <
class W,
class R>
705 template <
class W,
class R>
706 class ServerReaderWriterBody final {
710 : call_(call), ctx_(ctx) {}
717 ctx_->initial_metadata_flags());
718 if (ctx_->compression_level_set()) {
721 ctx_->sent_initial_metadata_ =
true;
723 call_->
cq()->Pluck(&ops);
733 ops.RecvMessage(msg);
735 return call_->
cq()->Pluck(&ops) && ops.got_message;
742 if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
745 if (!ctx_->sent_initial_metadata_) {
746 ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
747 ctx_->initial_metadata_flags());
748 if (ctx_->compression_level_set()) {
749 ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
751 ctx_->sent_initial_metadata_ =
true;
758 ctx_->has_pending_ops_ =
true;
761 ctx_->has_pending_ops_ =
false;
762 return call_->
cq()->Pluck(&ctx_->pending_ops_);
776 template <
class W,
class R>
785 return body_.NextMessageSize(sz);
788 bool Read(R* msg)
override {
return body_.Read(msg); }
797 return body_.Write(msg, options);
803 friend class ::grpc::internal::TemplatedBidiStreamingHandler<
807 : body_(call, ctx) {}
818 template <
class RequestType,
class ResponseType>
830 return body_.NextMessageSize(sz);
843 bool Read(RequestType* request)
override {
848 return body_.Read(request);
859 bool Write(
const ResponseType& response,
861 if (write_done_ || !read_done_) {
865 return body_.Write(response, options);
873 friend class ::grpc::internal::TemplatedBidiStreamingHandler<
877 : body_(call, ctx), read_done_(false), write_done_(false) {}
885 template <
class RequestType,
class ResponseType>
897 return body_.NextMessageSize(sz);
910 bool Read(RequestType* request)
override {
915 return body_.Read(request);
926 bool Write(
const ResponseType& response,
928 return read_done_ && body_.Write(response, options);
935 friend class ::grpc::internal::TemplatedBidiStreamingHandler<
939 : body_(call, ctx), read_done_(false) {}
944 #endif // GRPCPP_IMPL_CODEGEN_SYNC_STREAM_IMPL_H ::grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream_impl.h:527
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream_impl.h:584
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:796
virtual ~ReaderInterface()
Definition: sync_stream_impl.h:83
::grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream_impl.h:222
WriteOptions & set_buffer_hint()
Sets flag indicating that the write may be buffered and need not go out on the wire immediately...
Definition: call_op_set.h:125
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:145
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: channel_interface.h:35
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream_impl.h:637
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:492
static ClientReader< R > * Create(::grpc::ChannelInterface *channel, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context, const W &request)
Definition: sync_stream_impl.h:163
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream_impl.h:515
::grpc_impl::ServerSplitStreamer< RequestType, ResponseType > ServerSplitStreamer
Definition: sync_stream.h:96
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: channel_interface.h:31
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call_op_set.h:164
::grpc_impl::CompletionQueue * cq() const
Definition: call.h:73
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream_impl.h:829
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream_impl.h:205
Definition: sync_stream_impl.h:160
Primary implementation of CallOpSetInterface.
Definition: call_op_set.h:821
Server-side interface for bi-directional streaming.
Definition: sync_stream_impl.h:699
Definition: sync_stream_impl.h:431
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:720
bool Write(const ResponseType &response, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:926
Definition: completion_queue_impl.h:62
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream_impl.h:910
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:320
bool Write(const W &msg, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:658
Definition: grpc_types.h:722
A ServerContext allows the person implementing a service handler to:
Definition: server_context_impl.h:118
Server-side interface for streaming writes of message of type W.
Definition: sync_stream_impl.h:624
virtual ::grpc::Status Finish()=0
Block waiting until the stream finishes and a final status of the call is available.
::google::protobuf::util::Status Status
Definition: config_protobuf.h:96
virtual ~WriterInterface()
Definition: sync_stream_impl.h:106
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue_impl.h:57
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream_impl.h:784
::grpc_impl::ServerReader< R > ServerReader
Definition: sync_stream.h:75
::grpc_impl::ServerUnaryStreamer< RequestType, ResponseType > ServerUnaryStreamer
Definition: sync_stream.h:92
Events are popped out by calling grpc_completion_queue_pluck() API ONLY.
Definition: grpc_types.h:695
::grpc_impl::ServerReaderWriter< W, R > ServerReaderWriter
Definition: sync_stream.h:88
Definition: call_op_set.h:288
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream_impl.h:843
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream_impl.h:599
Definition: sync_stream_impl.h:279
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream_impl.h:788
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_impl.h:59
::grpc_impl::ClientReaderWriter< W, R > ClientReaderWriter
Definition: sync_stream.h:69
bool NextMessageSize(uint32_t *sz)
Definition: sync_stream_impl.h:726
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream_impl.h:195
bool Write(const W &msg, ::grpc::WriteOptions options)
Definition: sync_stream_impl.h:738
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream_impl.h:896
::grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream_impl.h:356
Codegen interface for grpc::Channel.
Definition: channel_interface.h:70
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream_impl.h:826
Client-side interface for streaming writes of message type W.
Definition: sync_stream_impl.h:265
The completion queue will have an associated pollset and there is no restriction on the type of file ...
Definition: grpc_types.h:675
static ClientWriter< W > * Create(::grpc::ChannelInterface *channel, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context, R *response)
Definition: sync_stream_impl.h:282
bool Write(const W &msg)
Block to write msg to the stream with default write options.
Definition: sync_stream_impl.h:123
An interface that can be fed a sequence of messages of type W.
Definition: sync_stream_impl.h:104
::grpc_impl::ClientWriter< W > ClientWriter
Definition: sync_stream.h:62
Definition: byte_buffer.h:52
Per-message write options.
Definition: call_op_set.h:85
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream_impl.h:343
bool Write(const ResponseType &response, ::grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream_impl.h:859
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream_impl.h:893
A class to represent a flow-controlled unary call.
Definition: sync_stream_impl.h:819
A class to represent a flow-controlled server-side streaming call.
Definition: sync_stream_impl.h:886
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream_impl.h:474
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm_impl.h:33
Definition: call_op_set.h:594
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream_impl.h:604
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream_impl.h:465
void RecvMessage(R *message)
Definition: call_op_set.h:431
static ClientReaderWriter< W, R > * Create(::grpc::ChannelInterface *channel, const ::grpc::internal::RpcMethod &method, ::grpc_impl::ClientContext *context)
Definition: sync_stream_impl.h:433
int max_receive_message_size() const
Definition: call.h:75
virtual ~ServerStreamingInterface()
Definition: sync_stream_impl.h:68
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue_impl.h:101
void SendInitialMetadata()
Definition: sync_stream_impl.h:712
void WriteLast(const W &msg, ::grpc::WriteOptions options)
Write msg and coalesce it with the writing of trailing metadata, using WriteOptions options...
Definition: sync_stream_impl.h:139
void WaitForInitialMetadata() override
Block waiting to read initial metadata from the server.
Definition: sync_stream_impl.h:455
A ClientContext allows the person implementing a service client to:
Definition: client_context_impl.h:180
Did it work? If it didn't, why?
Definition: status.h:31
Common interface for all synchronous client side streaming.
Definition: sync_stream_impl.h:34
Client-side interface for bi-directional streaming with client-to-server stream messages of type W an...
Definition: sync_stream_impl.h:410
::grpc_impl::ServerWriter< W > ServerWriter
Definition: sync_stream.h:81
Definition: call_op_set.h:516
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:68
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_op_set.h:189
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream_impl.h:782
Definition: call_op_set.h:744
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: channel_interface.h:33
Synchronous (blocking) server-side API for a bidirectional streaming call, where the incoming message...
Definition: sync_stream_impl.h:777
Client-side interface for streaming reads of message of type R.
Definition: sync_stream_impl.h:148
bool Read(R *msg)
Definition: sync_stream_impl.h:731
ServerReaderWriterBody(grpc::internal::Call *call, ::grpc_impl::ServerContext *ctx)
Definition: sync_stream_impl.h:708
An interface that yields a sequence of messages of type R.
Definition: sync_stream_impl.h:81
virtual ~ClientStreamingInterface()
Definition: sync_stream_impl.h:36
void WaitForInitialMetadata() override
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream_impl.h:185
Common interface for all synchronous server side streaming.
Definition: sync_stream_impl.h:66
void WaitForInitialMetadata()
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream_impl.h:303
::grpc_impl::ClientReader< R > ClientReader
Definition: sync_stream.h:56
Server-side interface for streaming reads of message of type R.
Definition: sync_stream_impl.h:572
Straightforward wrapping of the C call object.
Definition: call.h:38