GRPC C++  1.62.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 <grpc/support/log.h>
23 #include <grpcpp/client_context.h>
25 #include <grpcpp/impl/call.h>
28 #include <grpcpp/server_context.h>
29 #include <grpcpp/support/status.h>
30 
31 namespace grpc {
32 
33 namespace internal {
36  public:
38 
63  virtual grpc::Status Finish() = 0;
64 };
65 
68  public:
70 
77  virtual void SendInitialMetadata() = 0;
78 };
79 
81 template <class R>
83  public:
84  virtual ~ReaderInterface() {}
85 
88  virtual bool NextMessageSize(uint32_t* sz) = 0;
89 
100  virtual bool Read(R* msg) = 0;
101 };
102 
104 template <class W>
106  public:
107  virtual ~WriterInterface() {}
108 
116  virtual bool Write(const W& msg, grpc::WriteOptions options) = 0;
117 
124  inline bool Write(const W& msg) { return Write(msg, grpc::WriteOptions()); }
125 
140  void WriteLast(const W& msg, grpc::WriteOptions options) {
141  Write(msg, options.set_last_message());
142  }
143 };
144 
145 } // namespace internal
146 
148 template <class R>
150  public internal::ReaderInterface<R> {
151  public:
156  virtual void WaitForInitialMetadata() = 0;
157 };
158 
159 namespace internal {
160 template <class R>
162  public:
163  template <class W>
165  const grpc::internal::RpcMethod& method,
166  grpc::ClientContext* context,
167  const W& request) {
168  return new ClientReader<R>(channel, method, context, request);
169  }
170 };
171 } // namespace internal
172 
176 template <class R>
177 class ClientReader final : public ClientReaderInterface<R> {
178  public:
182  // Side effect:
186  void WaitForInitialMetadata() override {
187  GPR_ASSERT(!context_->initial_metadata_received_);
188 
190  ops.RecvInitialMetadata(context_);
191  call_.PerformOps(&ops);
192  cq_.Pluck(&ops);
193  }
194 
195  bool NextMessageSize(uint32_t* sz) override {
196  int result = call_.max_receive_message_size();
197  *sz = (result > 0) ? result : UINT32_MAX;
198  return true;
199  }
200 
206  bool Read(R* msg) override {
209  ops;
210  if (!context_->initial_metadata_received_) {
211  ops.RecvInitialMetadata(context_);
212  }
213  ops.RecvMessage(msg);
214  call_.PerformOps(&ops);
215  return cq_.Pluck(&ops) && ops.got_message;
216  }
217 
223  grpc::Status Finish() override {
226  ops;
227  if (!context_->initial_metadata_received_) {
228  ops.RecvInitialMetadata(context_);
229  }
230  grpc::Status status;
231  ops.ClientRecvStatus(context_, &status);
232  call_.PerformOps(&ops);
233  GPR_ASSERT(cq_.Pluck(&ops));
234  return status;
235  }
236 
237  private:
239  grpc::ClientContext* context_;
241  grpc::internal::Call call_;
242 
246  template <class W>
248  const grpc::internal::RpcMethod& method,
249  grpc::ClientContext* context, const W& request)
250  : context_(context),
253  nullptr}), // Pluckable cq
254  call_(channel->CreateCall(method, context, &cq_)) {
258  ops;
259  ops.SendInitialMetadata(&context->send_initial_metadata_,
260  context->initial_metadata_flags());
261  // TODO(ctiller): don't assert
262  GPR_ASSERT(ops.SendMessagePtr(&request).ok());
263  ops.ClientSendClose();
264  call_.PerformOps(&ops);
265  cq_.Pluck(&ops);
266  }
267 };
268 
270 template <class W>
272  public internal::WriterInterface<W> {
273  public:
280  virtual bool WritesDone() = 0;
281 };
282 
283 namespace internal {
284 template <class W>
286  public:
287  template <class R>
289  const grpc::internal::RpcMethod& method,
290  grpc::ClientContext* context, R* response) {
291  return new ClientWriter<W>(channel, method, context, response);
292  }
293 };
294 } // namespace internal
295 
299 template <class W>
300 class ClientWriter : public ClientWriterInterface<W> {
301  public:
305  // Side effect:
309  GPR_ASSERT(!context_->initial_metadata_received_);
310 
312  ops.RecvInitialMetadata(context_);
313  call_.PerformOps(&ops);
314  cq_.Pluck(&ops); // status ignored
315  }
316 
324  bool Write(const W& msg, grpc::WriteOptions options) override {
328  ops;
329 
330  if (options.is_last_message()) {
331  options.set_buffer_hint();
332  ops.ClientSendClose();
333  }
334  if (context_->initial_metadata_corked_) {
335  ops.SendInitialMetadata(&context_->send_initial_metadata_,
336  context_->initial_metadata_flags());
337  context_->set_initial_metadata_corked(false);
338  }
339  if (!ops.SendMessagePtr(&msg, options).ok()) {
340  return false;
341  }
342 
343  call_.PerformOps(&ops);
344  return cq_.Pluck(&ops);
345  }
346 
347  bool WritesDone() override {
349  ops.ClientSendClose();
350  call_.PerformOps(&ops);
351  return cq_.Pluck(&ops);
352  }
353 
360  grpc::Status Finish() override {
361  grpc::Status status;
362  if (!context_->initial_metadata_received_) {
363  finish_ops_.RecvInitialMetadata(context_);
364  }
365  finish_ops_.ClientRecvStatus(context_, &status);
366  call_.PerformOps(&finish_ops_);
367  GPR_ASSERT(cq_.Pluck(&finish_ops_));
368  return status;
369  }
370 
371  private:
373 
379  template <class R>
381  const grpc::internal::RpcMethod& method,
382  grpc::ClientContext* context, R* response)
383  : context_(context),
386  nullptr}), // Pluckable cq
387  call_(channel->CreateCall(method, context, &cq_)) {
388  finish_ops_.RecvMessage(response);
389  finish_ops_.AllowNoMessage();
390 
391  if (!context_->initial_metadata_corked_) {
393  ops.SendInitialMetadata(&context->send_initial_metadata_,
394  context->initial_metadata_flags());
395  call_.PerformOps(&ops);
396  cq_.Pluck(&ops);
397  }
398  }
399 
400  grpc::ClientContext* context_;
404  finish_ops_;
406  grpc::internal::Call call_;
407 };
408 
412 template <class W, class R>
414  public internal::WriterInterface<W>,
415  public internal::ReaderInterface<R> {
416  public:
421  virtual void WaitForInitialMetadata() = 0;
422 
429  virtual bool WritesDone() = 0;
430 };
431 
432 namespace internal {
433 template <class W, class R>
435  public:
437  grpc::ChannelInterface* channel, const grpc::internal::RpcMethod& method,
438  grpc::ClientContext* context) {
439  return new ClientReaderWriter<W, R>(channel, method, context);
440  }
441 };
442 } // namespace internal
443 
448 template <class W, class R>
449 class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
450  public:
457  void WaitForInitialMetadata() override {
458  GPR_ASSERT(!context_->initial_metadata_received_);
459 
461  ops.RecvInitialMetadata(context_);
462  call_.PerformOps(&ops);
463  cq_.Pluck(&ops); // status ignored
464  }
465 
466  bool NextMessageSize(uint32_t* sz) override {
467  int result = call_.max_receive_message_size();
468  *sz = (result > 0) ? result : UINT32_MAX;
469  return true;
470  }
471 
476  bool Read(R* msg) override {
479  ops;
480  if (!context_->initial_metadata_received_) {
481  ops.RecvInitialMetadata(context_);
482  }
483  ops.RecvMessage(msg);
484  call_.PerformOps(&ops);
485  return cq_.Pluck(&ops) && ops.got_message;
486  }
487 
494  bool Write(const W& msg, grpc::WriteOptions options) override {
498  ops;
499 
500  if (options.is_last_message()) {
501  options.set_buffer_hint();
502  ops.ClientSendClose();
503  }
504  if (context_->initial_metadata_corked_) {
505  ops.SendInitialMetadata(&context_->send_initial_metadata_,
506  context_->initial_metadata_flags());
507  context_->set_initial_metadata_corked(false);
508  }
509  if (!ops.SendMessagePtr(&msg, options).ok()) {
510  return false;
511  }
512 
513  call_.PerformOps(&ops);
514  return cq_.Pluck(&ops);
515  }
516 
517  bool WritesDone() override {
519  ops.ClientSendClose();
520  call_.PerformOps(&ops);
521  return cq_.Pluck(&ops);
522  }
523 
529  grpc::Status Finish() override {
532  ops;
533  if (!context_->initial_metadata_received_) {
534  ops.RecvInitialMetadata(context_);
535  }
536  grpc::Status status;
537  ops.ClientRecvStatus(context_, &status);
538  call_.PerformOps(&ops);
539  GPR_ASSERT(cq_.Pluck(&ops));
540  return status;
541  }
542 
543  private:
545 
546  grpc::ClientContext* context_;
548  grpc::internal::Call call_;
549 
554  const grpc::internal::RpcMethod& method,
555  grpc::ClientContext* context)
556  : context_(context),
559  nullptr}), // Pluckable cq
560  call_(channel->CreateCall(method, context, &cq_)) {
561  if (!context_->initial_metadata_corked_) {
563  ops.SendInitialMetadata(&context->send_initial_metadata_,
564  context->initial_metadata_flags());
565  call_.PerformOps(&ops);
566  cq_.Pluck(&ops);
567  }
568  }
569 };
570 
572 template <class R>
574  public internal::ReaderInterface<R> {};
575 
579 template <class R>
580 class ServerReader final : public ServerReaderInterface<R> {
581  public:
585  void SendInitialMetadata() override {
586  GPR_ASSERT(!ctx_->sent_initial_metadata_);
587 
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());
593  }
594  ctx_->sent_initial_metadata_ = true;
595  call_->PerformOps(&ops);
596  call_->cq()->Pluck(&ops);
597  }
598 
599  bool NextMessageSize(uint32_t* sz) override {
600  int result = call_->max_receive_message_size();
601  *sz = (result > 0) ? result : UINT32_MAX;
602  return true;
603  }
604 
605  bool Read(R* msg) override {
607  ops.RecvMessage(msg);
608  call_->PerformOps(&ops);
609  bool ok = call_->cq()->Pluck(&ops) && ops.got_message;
610  if (!ok) {
611  ctx_->MaybeMarkCancelledOnRead();
612  }
613  return ok;
614  }
615 
616  private:
617  grpc::internal::Call* const call_;
618  ServerContext* const ctx_;
619 
620  template <class ServiceType, class RequestType, class ResponseType>
622 
624  : call_(call), ctx_(ctx) {}
625 };
626 
628 template <class W>
630  public internal::WriterInterface<W> {};
631 
635 template <class W>
636 class ServerWriter final : public ServerWriterInterface<W> {
637  public:
642  void SendInitialMetadata() override {
643  GPR_ASSERT(!ctx_->sent_initial_metadata_);
644 
646  ops.SendInitialMetadata(&ctx_->initial_metadata_,
647  ctx_->initial_metadata_flags());
648  if (ctx_->compression_level_set()) {
649  ops.set_compression_level(ctx_->compression_level());
650  }
651  ctx_->sent_initial_metadata_ = true;
652  call_->PerformOps(&ops);
653  call_->cq()->Pluck(&ops);
654  }
655 
662  bool Write(const W& msg, grpc::WriteOptions options) override {
663  if (options.is_last_message()) {
664  options.set_buffer_hint();
665  }
666 
667  if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
668  return false;
669  }
670  if (!ctx_->sent_initial_metadata_) {
671  ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
672  ctx_->initial_metadata_flags());
673  if (ctx_->compression_level_set()) {
674  ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
675  }
676  ctx_->sent_initial_metadata_ = true;
677  }
678  call_->PerformOps(&ctx_->pending_ops_);
679  // if this is the last message we defer the pluck until AFTER we start
680  // the trailing md op. This prevents hangs. See
681  // https://github.com/grpc/grpc/issues/11546
682  if (options.is_last_message()) {
683  ctx_->has_pending_ops_ = true;
684  return true;
685  }
686  ctx_->has_pending_ops_ = false;
687  return call_->cq()->Pluck(&ctx_->pending_ops_);
688  }
689 
690  private:
691  grpc::internal::Call* const call_;
692  grpc::ServerContext* const ctx_;
693 
694  template <class ServiceType, class RequestType, class ResponseType>
696 
698  : call_(call), ctx_(ctx) {}
699 };
700 
702 template <class W, class R>
704  public internal::WriterInterface<W>,
705  public internal::ReaderInterface<R> {};
706 
708 namespace internal {
709 template <class W, class R>
710 class ServerReaderWriterBody final {
711  public:
713  : call_(call), ctx_(ctx) {}
714 
716  GPR_ASSERT(!ctx_->sent_initial_metadata_);
717 
719  ops.SendInitialMetadata(&ctx_->initial_metadata_,
720  ctx_->initial_metadata_flags());
721  if (ctx_->compression_level_set()) {
722  ops.set_compression_level(ctx_->compression_level());
723  }
724  ctx_->sent_initial_metadata_ = true;
725  call_->PerformOps(&ops);
726  call_->cq()->Pluck(&ops);
727  }
728 
729  bool NextMessageSize(uint32_t* sz) {
730  int result = call_->max_receive_message_size();
731  *sz = (result > 0) ? result : UINT32_MAX;
732  return true;
733  }
734 
735  bool Read(R* msg) {
737  ops.RecvMessage(msg);
738  call_->PerformOps(&ops);
739  bool ok = call_->cq()->Pluck(&ops) && ops.got_message;
740  if (!ok) {
741  ctx_->MaybeMarkCancelledOnRead();
742  }
743  return ok;
744  }
745 
746  bool Write(const W& msg, grpc::WriteOptions options) {
747  if (options.is_last_message()) {
748  options.set_buffer_hint();
749  }
750  if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
751  return false;
752  }
753  if (!ctx_->sent_initial_metadata_) {
754  ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
755  ctx_->initial_metadata_flags());
756  if (ctx_->compression_level_set()) {
757  ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
758  }
759  ctx_->sent_initial_metadata_ = true;
760  }
761  call_->PerformOps(&ctx_->pending_ops_);
762  // if this is the last message we defer the pluck until AFTER we start
763  // the trailing md op. This prevents hangs. See
764  // https://github.com/grpc/grpc/issues/11546
765  if (options.is_last_message()) {
766  ctx_->has_pending_ops_ = true;
767  return true;
768  }
769  ctx_->has_pending_ops_ = false;
770  return call_->cq()->Pluck(&ctx_->pending_ops_);
771  }
772 
773  private:
774  grpc::internal::Call* const call_;
775  grpc::ServerContext* const ctx_;
776 };
777 
778 } // namespace internal
779 
784 template <class W, class R>
786  public:
790  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
791 
792  bool NextMessageSize(uint32_t* sz) override {
793  return body_.NextMessageSize(sz);
794  }
795 
796  bool Read(R* msg) override { return body_.Read(msg); }
797 
804  bool Write(const W& msg, grpc::WriteOptions options) override {
805  return body_.Write(msg, options);
806  }
807 
808  private:
810 
812  false>;
814  : body_(call, ctx) {}
815 };
816 
825 template <class RequestType, class ResponseType>
827  : public ServerReaderWriterInterface<ResponseType, RequestType> {
828  public:
833  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
834 
836  bool NextMessageSize(uint32_t* sz) override {
837  return body_.NextMessageSize(sz);
838  }
839 
850  bool Read(RequestType* request) override {
851  if (read_done_) {
852  return false;
853  }
854  read_done_ = true;
855  return body_.Read(request);
856  }
857 
866  bool Write(const ResponseType& response,
867  grpc::WriteOptions options) override {
868  if (write_done_ || !read_done_) {
869  return false;
870  }
871  write_done_ = true;
872  return body_.Write(response, options);
873  }
874 
875  private:
877  bool read_done_;
878  bool write_done_;
879 
881  ServerUnaryStreamer<RequestType, ResponseType>, true>;
883  : body_(call, ctx), read_done_(false), write_done_(false) {}
884 };
885 
891 template <class RequestType, class ResponseType>
893  : public ServerReaderWriterInterface<ResponseType, RequestType> {
894  public:
899  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
900 
902  bool NextMessageSize(uint32_t* sz) override {
903  return body_.NextMessageSize(sz);
904  }
905 
916  bool Read(RequestType* request) override {
917  if (read_done_) {
918  return false;
919  }
920  read_done_ = true;
921  return body_.Read(request);
922  }
923 
932  bool Write(const ResponseType& response,
933  grpc::WriteOptions options) override {
934  return read_done_ && body_.Write(response, options);
935  }
936 
937  private:
939  bool read_done_;
940 
942  ServerSplitStreamer<RequestType, ResponseType>, false>;
944  : body_(call, ctx), read_done_(false) {}
945 };
946 
947 } // namespace grpc
948 
949 #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:866
grpc::internal::Call::cq
grpc::CompletionQueue * cq() const
Definition: call.h:71
grpc::internal::CallOpRecvInitialMetadata
Definition: call_op_set.h:721
grpc::internal::ServerReaderWriterBody::ServerReaderWriterBody
ServerReaderWriterBody(grpc::internal::Call *call, grpc::ServerContext *ctx)
Definition: sync_stream.h:712
grpc::ServerWriterInterface
Server-side interface for streaming writes of message of type W.
Definition: sync_stream.h:629
grpc::internal::ServerReaderWriterBody::SendInitialMetadata
void SendInitialMetadata()
Definition: sync_stream.h:715
grpc::internal::CallOpClientSendClose
Definition: call_op_set.h:619
grpc::internal::CallOpGenericRecvMessage
Definition: call_op_set.h:526
grpc::ClientReaderWriter::WritesDone
bool WritesDone() override
Definition: sync_stream.h:517
grpc::ClientWriter
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: client_context.h:81
grpc::ServerContext
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:572
grpc::ClientReader::WaitForInitialMetadata
void WaitForInitialMetadata() override
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:186
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:288
grpc::internal::CallOpSendMessage
Definition: call_op_set.h:286
grpc::ClientReaderWriter::Read
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:476
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:155
grpc::internal::WriterInterface::Write
bool Write(const W &msg)
Block to write msg to the stream with default write options.
Definition: sync_stream.h:124
grpc::ServerWriter
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs,...
Definition: completion_queue.h:61
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:932
grpc::internal::ClientReaderFactory
Definition: sync_stream.h:161
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:36
GPR_ASSERT
#define GPR_ASSERT(x)
abort() the process if x is zero, having written a line to the log.
Definition: log.h:95
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:223
grpc::ClientReaderWriterInterface
Client-side interface for bi-directional streaming with client-to-server stream messages of type W an...
Definition: sync_stream.h:413
status.h
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:216
grpc::ClientWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Definition: sync_stream.h:324
grpc::ClientWriter::Finish
grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:360
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:902
grpc::ServerSplitStreamer
A class to represent a flow-controlled server-side streaming call.
Definition: sync_stream.h:892
grpc::internal::ServerReaderWriterBody
Definition: completion_queue.h:64
grpc::internal::ServerStreamingInterface::~ServerStreamingInterface
virtual ~ServerStreamingInterface()
Definition: sync_stream.h:69
grpc::ClientReaderWriter::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Definition: sync_stream.h:466
grpc::ServerReader::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Definition: sync_stream.h:599
grpc::ServerUnaryStreamer::Read
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:850
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:35
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:415
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:79
grpc::internal::ClientReaderWriterFactory
Definition: sync_stream.h:434
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:105
grpc::ServerReader
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:59
completion_queue.h
grpc::ClientContext
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:193
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:804
grpc::ServerWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Definition: sync_stream.h:662
grpc::ServerReaderWriterInterface
Server-side interface for bi-directional streaming.
Definition: sync_stream.h:703
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:271
grpc::ClientReader::Read
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:206
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:195
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:836
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:792
grpc::internal::ServerReaderWriterBody::Write
bool Write(const W &msg, grpc::WriteOptions options)
Definition: sync_stream.h:746
grpc::ClientWriter::WaitForInitialMetadata
void WaitForInitialMetadata()
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:308
GRPC_CQ_PLUCK
@ GRPC_CQ_PLUCK
Events are popped out by calling grpc_completion_queue_pluck() API ONLY.
Definition: grpc_types.h:435
grpc_completion_queue_attributes
Definition: grpc_types.h:463
grpc::internal::ClientStreamingInterface
Common interface for all synchronous client side streaming.
Definition: sync_stream.h:35
grpc::internal::ServerReaderWriterBody::NextMessageSize
bool NextMessageSize(uint32_t *sz)
Definition: sync_stream.h:729
grpc::ServerSplitStreamer::SendInitialMetadata
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:899
grpc::ServerReaderWriter::Read
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream.h:796
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:78
grpc::ServerReaderWriter
Synchronous (blocking) server-side API for a bidirectional streaming call, where the incoming message...
Definition: sync_stream.h:785
client_context.h
grpc::internal::ServerStreamingHandler
A wrapper class of an application provided server streaming handler.
Definition: completion_queue.h:76
grpc::internal::WriterInterface::~WriterInterface
virtual ~WriterInterface()
Definition: sync_stream.h:107
grpc::ClientReaderWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Definition: sync_stream.h:494
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:164
grpc::ClientReaderWriter::Finish
grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:529
grpc::internal::ClientStreamingHandler
A wrapper class of an application provided client streaming handler.
Definition: completion_queue.h:74
channel_interface.h
grpc::ClientReaderInterface
Client-side interface for streaming reads of message of type R.
Definition: sync_stream.h:149
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:78
GRPC_CQ_CURRENT_VERSION
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:461
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:585
grpc::internal::Call::PerformOps
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:66
grpc::internal::ServerReaderWriterBody::Read
bool Read(R *msg)
Definition: sync_stream.h:735
grpc::ClientReaderWriter
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: client_context.h:83
server_context.h
call.h
grpc::internal::ReaderInterface::~ReaderInterface
virtual ~ReaderInterface()
Definition: sync_stream.h:84
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:573
grpc::ClientReaderWriter::WaitForInitialMetadata
void WaitForInitialMetadata() override
Block waiting to read initial metadata from the server.
Definition: sync_stream.h:457
grpc::internal::ClientReaderWriterFactory::Create
static ClientReaderWriter< W, R > * Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context)
Definition: sync_stream.h:436
grpc::internal::CallOpClientRecvStatus
Definition: call_op_set.h:769
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:116
service_type.h
grpc::CompletionQueue
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:103
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:790
grpc::internal::ReaderInterface
An interface that yields a sequence of messages of type R.
Definition: sync_stream.h:82
grpc::ServerWriter::SendInitialMetadata
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:642
grpc::ServerUnaryStreamer
A class to represent a flow-controlled unary call.
Definition: sync_stream.h:826
grpc::ServerUnaryStreamer::SendInitialMetadata
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:833
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:171
grpc::internal::CallOpRecvMessage
Definition: call_op_set.h:424
grpc::internal::RpcMethod
Descriptor of an RPC method.
Definition: rpc_method.h:29
grpc::internal::ClientWriterFactory
Definition: sync_stream.h:285
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:140
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:916
grpc::ClientWriterInterface::WritesDone
virtual bool WritesDone()=0
Half close writing from the client.
grpc::internal::ClientStreamingInterface::~ClientStreamingInterface
virtual ~ClientStreamingInterface()
Definition: sync_stream.h:37
grpc::ClientWriter::WritesDone
bool WritesDone() override
Definition: sync_stream.h:347
grpc::internal::CallOpRecvMessage::RecvMessage
void RecvMessage(R *message)
Definition: call_op_set.h:426
grpc::internal::ServerStreamingInterface
Common interface for all synchronous server side streaming.
Definition: sync_stream.h:67
grpc::ServerReader::Read
bool Read(R *msg) override
Definition: sync_stream.h:605