GRPC C++  1.66.0
sync_stream.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2015 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #ifndef GRPCPP_SUPPORT_SYNC_STREAM_H
20 #define GRPCPP_SUPPORT_SYNC_STREAM_H
21 
22 #include "absl/log/absl_check.h"
23 
24 #include <grpc/support/log.h>
25 #include <grpcpp/client_context.h>
27 #include <grpcpp/impl/call.h>
30 #include <grpcpp/server_context.h>
31 #include <grpcpp/support/status.h>
32 
33 namespace grpc {
34 
35 namespace internal {
38  public:
40 
65  virtual grpc::Status Finish() = 0;
66 };
67 
70  public:
72 
79  virtual void SendInitialMetadata() = 0;
80 };
81 
83 template <class R>
85  public:
86  virtual ~ReaderInterface() {}
87 
90  virtual bool NextMessageSize(uint32_t* sz) = 0;
91 
102  virtual bool Read(R* msg) = 0;
103 };
104 
106 template <class W>
108  public:
109  virtual ~WriterInterface() {}
110 
118  virtual bool Write(const W& msg, grpc::WriteOptions options) = 0;
119 
126  inline bool Write(const W& msg) { return Write(msg, grpc::WriteOptions()); }
127 
142  void WriteLast(const W& msg, grpc::WriteOptions options) {
143  Write(msg, options.set_last_message());
144  }
145 };
146 
147 } // namespace internal
148 
150 template <class R>
152  public internal::ReaderInterface<R> {
153  public:
158  virtual void WaitForInitialMetadata() = 0;
159 };
160 
161 namespace internal {
162 template <class R>
164  public:
165  template <class W>
167  const grpc::internal::RpcMethod& method,
168  grpc::ClientContext* context,
169  const W& request) {
170  return new ClientReader<R>(channel, method, context, request);
171  }
172 };
173 } // namespace internal
174 
178 template <class R>
179 class ClientReader final : public ClientReaderInterface<R> {
180  public:
184  // Side effect:
188  void WaitForInitialMetadata() override {
189  ABSL_CHECK(!context_->initial_metadata_received_);
190 
192  ops.RecvInitialMetadata(context_);
193  call_.PerformOps(&ops);
194  cq_.Pluck(&ops);
195  }
196 
197  bool NextMessageSize(uint32_t* sz) override {
198  int result = call_.max_receive_message_size();
199  *sz = (result > 0) ? result : UINT32_MAX;
200  return true;
201  }
202 
208  bool Read(R* msg) override {
211  ops;
212  if (!context_->initial_metadata_received_) {
213  ops.RecvInitialMetadata(context_);
214  }
215  ops.RecvMessage(msg);
216  call_.PerformOps(&ops);
217  return cq_.Pluck(&ops) && ops.got_message;
218  }
219 
225  grpc::Status Finish() override {
228  ops;
229  if (!context_->initial_metadata_received_) {
230  ops.RecvInitialMetadata(context_);
231  }
232  grpc::Status status;
233  ops.ClientRecvStatus(context_, &status);
234  call_.PerformOps(&ops);
235  ABSL_CHECK(cq_.Pluck(&ops));
236  return status;
237  }
238 
239  private:
241  grpc::ClientContext* context_;
243  grpc::internal::Call call_;
244 
248  template <class W>
250  const grpc::internal::RpcMethod& method,
251  grpc::ClientContext* context, const W& request)
252  : context_(context),
255  nullptr}), // Pluckable cq
256  call_(channel->CreateCall(method, context, &cq_)) {
260  ops;
261  ops.SendInitialMetadata(&context->send_initial_metadata_,
262  context->initial_metadata_flags());
263  // TODO(ctiller): don't assert
264  ABSL_CHECK(ops.SendMessagePtr(&request).ok());
265  ops.ClientSendClose();
266  call_.PerformOps(&ops);
267  cq_.Pluck(&ops);
268  }
269 };
270 
272 template <class W>
274  public internal::WriterInterface<W> {
275  public:
282  virtual bool WritesDone() = 0;
283 };
284 
285 namespace internal {
286 template <class W>
288  public:
289  template <class R>
291  const grpc::internal::RpcMethod& method,
292  grpc::ClientContext* context, R* response) {
293  return new ClientWriter<W>(channel, method, context, response);
294  }
295 };
296 } // namespace internal
297 
301 template <class W>
302 class ClientWriter : public ClientWriterInterface<W> {
303  public:
307  // Side effect:
311  ABSL_CHECK(!context_->initial_metadata_received_);
312 
314  ops.RecvInitialMetadata(context_);
315  call_.PerformOps(&ops);
316  cq_.Pluck(&ops); // status ignored
317  }
318 
326  bool Write(const W& msg, grpc::WriteOptions options) override {
330  ops;
331 
332  if (options.is_last_message()) {
333  options.set_buffer_hint();
334  ops.ClientSendClose();
335  }
336  if (context_->initial_metadata_corked_) {
337  ops.SendInitialMetadata(&context_->send_initial_metadata_,
338  context_->initial_metadata_flags());
339  context_->set_initial_metadata_corked(false);
340  }
341  if (!ops.SendMessagePtr(&msg, options).ok()) {
342  return false;
343  }
344 
345  call_.PerformOps(&ops);
346  return cq_.Pluck(&ops);
347  }
348 
349  bool WritesDone() override {
351  ops.ClientSendClose();
352  call_.PerformOps(&ops);
353  return cq_.Pluck(&ops);
354  }
355 
362  grpc::Status Finish() override {
363  grpc::Status status;
364  if (!context_->initial_metadata_received_) {
365  finish_ops_.RecvInitialMetadata(context_);
366  }
367  finish_ops_.ClientRecvStatus(context_, &status);
368  call_.PerformOps(&finish_ops_);
369  ABSL_CHECK(cq_.Pluck(&finish_ops_));
370  return status;
371  }
372 
373  private:
375 
381  template <class R>
383  const grpc::internal::RpcMethod& method,
384  grpc::ClientContext* context, R* response)
385  : context_(context),
388  nullptr}), // Pluckable cq
389  call_(channel->CreateCall(method, context, &cq_)) {
390  finish_ops_.RecvMessage(response);
391  finish_ops_.AllowNoMessage();
392 
393  if (!context_->initial_metadata_corked_) {
395  ops.SendInitialMetadata(&context->send_initial_metadata_,
396  context->initial_metadata_flags());
397  call_.PerformOps(&ops);
398  cq_.Pluck(&ops);
399  }
400  }
401 
402  grpc::ClientContext* context_;
406  finish_ops_;
408  grpc::internal::Call call_;
409 };
410 
414 template <class W, class R>
416  public internal::WriterInterface<W>,
417  public internal::ReaderInterface<R> {
418  public:
423  virtual void WaitForInitialMetadata() = 0;
424 
431  virtual bool WritesDone() = 0;
432 };
433 
434 namespace internal {
435 template <class W, class R>
437  public:
439  grpc::ChannelInterface* channel, const grpc::internal::RpcMethod& method,
440  grpc::ClientContext* context) {
441  return new ClientReaderWriter<W, R>(channel, method, context);
442  }
443 };
444 } // namespace internal
445 
450 template <class W, class R>
451 class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
452  public:
459  void WaitForInitialMetadata() override {
460  ABSL_CHECK(!context_->initial_metadata_received_);
461 
463  ops.RecvInitialMetadata(context_);
464  call_.PerformOps(&ops);
465  cq_.Pluck(&ops); // status ignored
466  }
467 
468  bool NextMessageSize(uint32_t* sz) override {
469  int result = call_.max_receive_message_size();
470  *sz = (result > 0) ? result : UINT32_MAX;
471  return true;
472  }
473 
478  bool Read(R* msg) override {
481  ops;
482  if (!context_->initial_metadata_received_) {
483  ops.RecvInitialMetadata(context_);
484  }
485  ops.RecvMessage(msg);
486  call_.PerformOps(&ops);
487  return cq_.Pluck(&ops) && ops.got_message;
488  }
489 
496  bool Write(const W& msg, grpc::WriteOptions options) override {
500  ops;
501 
502  if (options.is_last_message()) {
503  options.set_buffer_hint();
504  ops.ClientSendClose();
505  }
506  if (context_->initial_metadata_corked_) {
507  ops.SendInitialMetadata(&context_->send_initial_metadata_,
508  context_->initial_metadata_flags());
509  context_->set_initial_metadata_corked(false);
510  }
511  if (!ops.SendMessagePtr(&msg, options).ok()) {
512  return false;
513  }
514 
515  call_.PerformOps(&ops);
516  return cq_.Pluck(&ops);
517  }
518 
519  bool WritesDone() override {
521  ops.ClientSendClose();
522  call_.PerformOps(&ops);
523  return cq_.Pluck(&ops);
524  }
525 
531  grpc::Status Finish() override {
534  ops;
535  if (!context_->initial_metadata_received_) {
536  ops.RecvInitialMetadata(context_);
537  }
538  grpc::Status status;
539  ops.ClientRecvStatus(context_, &status);
540  call_.PerformOps(&ops);
541  ABSL_CHECK(cq_.Pluck(&ops));
542  return status;
543  }
544 
545  private:
547 
548  grpc::ClientContext* context_;
550  grpc::internal::Call call_;
551 
556  const grpc::internal::RpcMethod& method,
557  grpc::ClientContext* context)
558  : context_(context),
561  nullptr}), // Pluckable cq
562  call_(channel->CreateCall(method, context, &cq_)) {
563  if (!context_->initial_metadata_corked_) {
565  ops.SendInitialMetadata(&context->send_initial_metadata_,
566  context->initial_metadata_flags());
567  call_.PerformOps(&ops);
568  cq_.Pluck(&ops);
569  }
570  }
571 };
572 
574 template <class R>
576  public internal::ReaderInterface<R> {};
577 
581 template <class R>
582 class ServerReader final : public ServerReaderInterface<R> {
583  public:
587  void SendInitialMetadata() override {
588  ABSL_CHECK(!ctx_->sent_initial_metadata_);
589 
591  ops.SendInitialMetadata(&ctx_->initial_metadata_,
592  ctx_->initial_metadata_flags());
593  if (ctx_->compression_level_set()) {
594  ops.set_compression_level(ctx_->compression_level());
595  }
596  ctx_->sent_initial_metadata_ = true;
597  call_->PerformOps(&ops);
598  call_->cq()->Pluck(&ops);
599  }
600 
601  bool NextMessageSize(uint32_t* sz) override {
602  int result = call_->max_receive_message_size();
603  *sz = (result > 0) ? result : UINT32_MAX;
604  return true;
605  }
606 
607  bool Read(R* msg) override {
609  ops.RecvMessage(msg);
610  call_->PerformOps(&ops);
611  bool ok = call_->cq()->Pluck(&ops) && ops.got_message;
612  if (!ok) {
613  ctx_->MaybeMarkCancelledOnRead();
614  }
615  return ok;
616  }
617 
618  private:
619  grpc::internal::Call* const call_;
620  ServerContext* const ctx_;
621 
622  template <class ServiceType, class RequestType, class ResponseType>
624 
626  : call_(call), ctx_(ctx) {}
627 };
628 
630 template <class W>
632  public internal::WriterInterface<W> {};
633 
637 template <class W>
638 class ServerWriter final : public ServerWriterInterface<W> {
639  public:
644  void SendInitialMetadata() override {
645  ABSL_CHECK(!ctx_->sent_initial_metadata_);
646 
648  ops.SendInitialMetadata(&ctx_->initial_metadata_,
649  ctx_->initial_metadata_flags());
650  if (ctx_->compression_level_set()) {
651  ops.set_compression_level(ctx_->compression_level());
652  }
653  ctx_->sent_initial_metadata_ = true;
654  call_->PerformOps(&ops);
655  call_->cq()->Pluck(&ops);
656  }
657 
664  bool Write(const W& msg, grpc::WriteOptions options) override {
665  if (options.is_last_message()) {
666  options.set_buffer_hint();
667  }
668 
669  if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
670  return false;
671  }
672  if (!ctx_->sent_initial_metadata_) {
673  ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
674  ctx_->initial_metadata_flags());
675  if (ctx_->compression_level_set()) {
676  ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
677  }
678  ctx_->sent_initial_metadata_ = true;
679  }
680  call_->PerformOps(&ctx_->pending_ops_);
681  // if this is the last message we defer the pluck until AFTER we start
682  // the trailing md op. This prevents hangs. See
683  // https://github.com/grpc/grpc/issues/11546
684  if (options.is_last_message()) {
685  ctx_->has_pending_ops_ = true;
686  return true;
687  }
688  ctx_->has_pending_ops_ = false;
689  return call_->cq()->Pluck(&ctx_->pending_ops_);
690  }
691 
692  private:
693  grpc::internal::Call* const call_;
694  grpc::ServerContext* const ctx_;
695 
696  template <class ServiceType, class RequestType, class ResponseType>
698 
700  : call_(call), ctx_(ctx) {}
701 };
702 
704 template <class W, class R>
706  public internal::WriterInterface<W>,
707  public internal::ReaderInterface<R> {};
708 
710 namespace internal {
711 template <class W, class R>
712 class ServerReaderWriterBody final {
713  public:
715  : call_(call), ctx_(ctx) {}
716 
718  ABSL_CHECK(!ctx_->sent_initial_metadata_);
719 
721  ops.SendInitialMetadata(&ctx_->initial_metadata_,
722  ctx_->initial_metadata_flags());
723  if (ctx_->compression_level_set()) {
724  ops.set_compression_level(ctx_->compression_level());
725  }
726  ctx_->sent_initial_metadata_ = true;
727  call_->PerformOps(&ops);
728  call_->cq()->Pluck(&ops);
729  }
730 
731  bool NextMessageSize(uint32_t* sz) {
732  int result = call_->max_receive_message_size();
733  *sz = (result > 0) ? result : UINT32_MAX;
734  return true;
735  }
736 
737  bool Read(R* msg) {
739  ops.RecvMessage(msg);
740  call_->PerformOps(&ops);
741  bool ok = call_->cq()->Pluck(&ops) && ops.got_message;
742  if (!ok) {
743  ctx_->MaybeMarkCancelledOnRead();
744  }
745  return ok;
746  }
747 
748  bool Write(const W& msg, grpc::WriteOptions options) {
749  if (options.is_last_message()) {
750  options.set_buffer_hint();
751  }
752  if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
753  return false;
754  }
755  if (!ctx_->sent_initial_metadata_) {
756  ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
757  ctx_->initial_metadata_flags());
758  if (ctx_->compression_level_set()) {
759  ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
760  }
761  ctx_->sent_initial_metadata_ = true;
762  }
763  call_->PerformOps(&ctx_->pending_ops_);
764  // if this is the last message we defer the pluck until AFTER we start
765  // the trailing md op. This prevents hangs. See
766  // https://github.com/grpc/grpc/issues/11546
767  if (options.is_last_message()) {
768  ctx_->has_pending_ops_ = true;
769  return true;
770  }
771  ctx_->has_pending_ops_ = false;
772  return call_->cq()->Pluck(&ctx_->pending_ops_);
773  }
774 
775  private:
776  grpc::internal::Call* const call_;
777  grpc::ServerContext* const ctx_;
778 };
779 
780 } // namespace internal
781 
786 template <class W, class R>
788  public:
792  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
793 
794  bool NextMessageSize(uint32_t* sz) override {
795  return body_.NextMessageSize(sz);
796  }
797 
798  bool Read(R* msg) override { return body_.Read(msg); }
799 
806  bool Write(const W& msg, grpc::WriteOptions options) override {
807  return body_.Write(msg, options);
808  }
809 
810  private:
812 
814  false>;
816  : body_(call, ctx) {}
817 };
818 
827 template <class RequestType, class ResponseType>
829  : public ServerReaderWriterInterface<ResponseType, RequestType> {
830  public:
835  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
836 
838  bool NextMessageSize(uint32_t* sz) override {
839  return body_.NextMessageSize(sz);
840  }
841 
852  bool Read(RequestType* request) override {
853  if (read_done_) {
854  return false;
855  }
856  read_done_ = true;
857  return body_.Read(request);
858  }
859 
868  bool Write(const ResponseType& response,
869  grpc::WriteOptions options) override {
870  if (write_done_ || !read_done_) {
871  return false;
872  }
873  write_done_ = true;
874  return body_.Write(response, options);
875  }
876 
877  private:
879  bool read_done_;
880  bool write_done_;
881 
883  ServerUnaryStreamer<RequestType, ResponseType>, true>;
885  : body_(call, ctx), read_done_(false), write_done_(false) {}
886 };
887 
893 template <class RequestType, class ResponseType>
895  : public ServerReaderWriterInterface<ResponseType, RequestType> {
896  public:
901  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
902 
904  bool NextMessageSize(uint32_t* sz) override {
905  return body_.NextMessageSize(sz);
906  }
907 
918  bool Read(RequestType* request) override {
919  if (read_done_) {
920  return false;
921  }
922  read_done_ = true;
923  return body_.Read(request);
924  }
925 
934  bool Write(const ResponseType& response,
935  grpc::WriteOptions options) override {
936  return read_done_ && body_.Write(response, options);
937  }
938 
939  private:
941  bool read_done_;
942 
944  ServerSplitStreamer<RequestType, ResponseType>, false>;
946  : body_(call, ctx), read_done_(false) {}
947 };
948 
949 } // namespace grpc
950 
951 #endif // GRPCPP_SUPPORT_SYNC_STREAM_H
grpc::ServerUnaryStreamer::Write
bool Write(const ResponseType &response, grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:868
grpc::internal::Call::cq
grpc::CompletionQueue * cq() const
Definition: call.h:71
grpc::internal::CallOpRecvInitialMetadata
Definition: call_op_set.h:723
grpc::internal::ServerReaderWriterBody::ServerReaderWriterBody
ServerReaderWriterBody(grpc::internal::Call *call, grpc::ServerContext *ctx)
Definition: sync_stream.h:714
grpc::ServerWriterInterface
Server-side interface for streaming writes of message of type W.
Definition: sync_stream.h:631
grpc::internal::ServerReaderWriterBody::SendInitialMetadata
void SendInitialMetadata()
Definition: sync_stream.h:717
grpc::internal::CallOpClientSendClose
Definition: call_op_set.h:621
grpc::internal::CallOpGenericRecvMessage
Definition: call_op_set.h:528
grpc::ClientReaderWriter::WritesDone
bool WritesDone() override
Definition: sync_stream.h:519
grpc::ClientWriter
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: client_context.h:83
grpc::ServerContext
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:578
grpc::ClientReader::WaitForInitialMetadata
void WaitForInitialMetadata() override
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:188
grpc::internal::Call::max_receive_message_size
int max_receive_message_size() const
Definition: call.h:73
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc::internal::CallOpSet< grpc::internal::CallOpRecvInitialMetadata >
grpc::internal::ClientWriterFactory::Create
static ClientWriter< W > * Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, R *response)
Definition: sync_stream.h:290
grpc::internal::CallOpSendMessage
Definition: call_op_set.h:288
grpc::ClientReaderWriter::Read
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:478
grpc::WriteOptions::set_last_message
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:157
grpc::internal::WriterInterface::Write
bool Write(const W &msg)
Block to write msg to the stream with default write options.
Definition: sync_stream.h:126
grpc::ServerWriter
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs,...
Definition: completion_queue.h:63
grpc::ServerSplitStreamer::Write
bool Write(const ResponseType &response, grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:934
grpc::internal::ClientReaderFactory
Definition: sync_stream.h:163
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:36
grpc::internal::ReaderInterface::NextMessageSize
virtual bool NextMessageSize(uint32_t *sz)=0
Get an upper bound on the next message size available for reading on this stream.
grpc::ClientReader::Finish
grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:225
grpc::ClientReaderWriterInterface
Client-side interface for bi-directional streaming with client-to-server stream messages of type W an...
Definition: sync_stream.h:415
status.h
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:218
grpc::ClientWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Definition: sync_stream.h:326
grpc::ClientWriter::Finish
grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:362
grpc::ServerSplitStreamer::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream.h:904
grpc::ServerSplitStreamer
A class to represent a flow-controlled server-side streaming call.
Definition: sync_stream.h:894
grpc::internal::ServerReaderWriterBody
Definition: completion_queue.h:66
grpc::internal::ServerStreamingInterface::~ServerStreamingInterface
virtual ~ServerStreamingInterface()
Definition: sync_stream.h:71
grpc::ClientReaderWriter::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Definition: sync_stream.h:468
grpc::ServerReader::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Definition: sync_stream.h:601
grpc::ServerUnaryStreamer::Read
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:852
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:34
GRPC_CQ_DEFAULT_POLLING
@ GRPC_CQ_DEFAULT_POLLING
The completion queue will have an associated pollset and there is no restriction on the type of file ...
Definition: grpc_types.h:414
grpc::ClientReaderWriterInterface::WaitForInitialMetadata
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
grpc::ServerContext::set_compression_level
void set_compression_level(grpc_compression_level level)
Set level to be the compression level used for the server call.
Definition: server_context.h:243
grpc::ClientReader
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: client_context.h:81
grpc::internal::ClientReaderWriterFactory
Definition: sync_stream.h:436
grpc::ServerContext::compression_level
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context.h:236
log.h
grpc::internal::WriterInterface
An interface that can be fed a sequence of messages of type W.
Definition: sync_stream.h:107
grpc::ServerReader
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:61
completion_queue.h
grpc::ClientContext
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:195
grpc::ServerReaderWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:806
grpc::ServerWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Definition: sync_stream.h:664
grpc::ServerReaderWriterInterface
Server-side interface for bi-directional streaming.
Definition: sync_stream.h:705
grpc::internal::ReaderInterface::Read
virtual bool Read(R *msg)=0
Block to read a message and parse to msg.
grpc::ClientWriterInterface
Client-side interface for streaming writes of message type W.
Definition: sync_stream.h:273
grpc::ClientReader::Read
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:208
grpc::ChannelInterface
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
grpc::ClientReader::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Definition: sync_stream.h:197
grpc::ServerUnaryStreamer::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream.h:838
grpc::ServerReaderWriter::NextMessageSize
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:794
grpc::internal::ServerReaderWriterBody::Write
bool Write(const W &msg, grpc::WriteOptions options)
Definition: sync_stream.h:748
grpc::ClientWriter::WaitForInitialMetadata
void WaitForInitialMetadata()
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:310
GRPC_CQ_PLUCK
@ GRPC_CQ_PLUCK
Events are popped out by calling grpc_completion_queue_pluck() API ONLY.
Definition: grpc_types.h:434
grpc_completion_queue_attributes
Definition: grpc_types.h:462
grpc::internal::ClientStreamingInterface
Common interface for all synchronous client side streaming.
Definition: sync_stream.h:37
grpc::internal::ServerReaderWriterBody::NextMessageSize
bool NextMessageSize(uint32_t *sz)
Definition: sync_stream.h:731
grpc::ServerSplitStreamer::SendInitialMetadata
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:901
grpc::ServerReaderWriter::Read
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream.h:798
grpc::internal::ServerStreamingInterface::SendInitialMetadata
virtual void SendInitialMetadata()=0
Block to send initial metadata to client.
grpc::WriteOptions
Per-message write options.
Definition: call_op_set.h:80
grpc::ServerReaderWriter
Synchronous (blocking) server-side API for a bidirectional streaming call, where the incoming message...
Definition: sync_stream.h:787
client_context.h
grpc::internal::ServerStreamingHandler
A wrapper class of an application provided server streaming handler.
Definition: completion_queue.h:78
grpc::internal::WriterInterface::~WriterInterface
virtual ~WriterInterface()
Definition: sync_stream.h:109
grpc::ClientReaderWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Definition: sync_stream.h:496
grpc::internal::ClientReaderFactory::Create
static ClientReader< R > * Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, const W &request)
Definition: sync_stream.h:166
grpc::ClientReaderWriter::Finish
grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:531
grpc::internal::ClientStreamingHandler
A wrapper class of an application provided client streaming handler.
Definition: completion_queue.h:76
channel_interface.h
grpc::ClientReaderInterface
Client-side interface for streaming reads of message of type R.
Definition: sync_stream.h:151
grpc::internal::WriterInterface::Write
virtual bool Write(const W &msg, grpc::WriteOptions options)=0
Block to write msg to the stream with WriteOptions options.
grpc::internal::TemplatedBidiStreamingHandler
A wrapper class of an application provided bidi-streaming handler.
Definition: completion_queue.h:80
GRPC_CQ_CURRENT_VERSION
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:460
grpc::ClientReaderInterface::WaitForInitialMetadata
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
grpc::ServerReader::SendInitialMetadata
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:587
grpc::internal::Call::PerformOps
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:66
grpc::internal::ServerReaderWriterBody::Read
bool Read(R *msg)
Definition: sync_stream.h:737
grpc::ClientReaderWriter
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: client_context.h:85
server_context.h
call.h
grpc::internal::ReaderInterface::~ReaderInterface
virtual ~ReaderInterface()
Definition: sync_stream.h:86
grpc::ServerContext::compression_level_set
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:251
grpc::ServerReaderInterface
Server-side interface for streaming reads of message of type R.
Definition: sync_stream.h:575
grpc::ClientReaderWriter::WaitForInitialMetadata
void WaitForInitialMetadata() override
Block waiting to read initial metadata from the server.
Definition: sync_stream.h:459
grpc::internal::ClientReaderWriterFactory::Create
static ClientReaderWriter< W, R > * Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context)
Definition: sync_stream.h:438
grpc::internal::CallOpClientRecvStatus
Definition: call_op_set.h:771
grpc::WriteOptions::set_buffer_hint
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:118
service_type.h
grpc::CompletionQueue
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:105
grpc::internal::ClientStreamingInterface::Finish
virtual grpc::Status Finish()=0
Block waiting until the stream finishes and a final status of the call is available.
grpc::ServerReaderWriter::SendInitialMetadata
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:792
grpc::internal::ReaderInterface
An interface that yields a sequence of messages of type R.
Definition: sync_stream.h:84
grpc::ServerWriter::SendInitialMetadata
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:644
grpc::ServerUnaryStreamer
A class to represent a flow-controlled unary call.
Definition: sync_stream.h:828
grpc::ServerUnaryStreamer::SendInitialMetadata
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:835
grpc::WriteOptions::is_last_message
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:173
grpc::internal::CallOpRecvMessage
Definition: call_op_set.h:426
grpc::internal::RpcMethod
Descriptor of an RPC method.
Definition: rpc_method.h:29
grpc::internal::ClientWriterFactory
Definition: sync_stream.h:287
grpc::internal::WriterInterface::WriteLast
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.h:142
grpc::ClientReaderWriterInterface::WritesDone
virtual bool WritesDone()=0
Half close writing from the client.
grpc::ServerSplitStreamer::Read
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:918
grpc::ClientWriterInterface::WritesDone
virtual bool WritesDone()=0
Half close writing from the client.
grpc::internal::ClientStreamingInterface::~ClientStreamingInterface
virtual ~ClientStreamingInterface()
Definition: sync_stream.h:39
grpc::ClientWriter::WritesDone
bool WritesDone() override
Definition: sync_stream.h:349
grpc::internal::CallOpRecvMessage::RecvMessage
void RecvMessage(R *message)
Definition: call_op_set.h:428
grpc::internal::ServerStreamingInterface
Common interface for all synchronous server side streaming.
Definition: sync_stream.h:69
grpc::ServerReader::Read
bool Read(R *msg) override
Definition: sync_stream.h:607