GRPC C++  1.46.2
sync_stream.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2019 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 #ifndef GRPCPP_IMPL_CODEGEN_SYNC_STREAM_H
19 #define GRPCPP_IMPL_CODEGEN_SYNC_STREAM_H
20 
21 // IWYU pragma: private, include <grpcpp/support/sync_stream.h>
22 
31 
32 namespace grpc {
33 
34 namespace internal {
37  public:
39 
64  virtual grpc::Status Finish() = 0;
65 };
66 
69  public:
71 
78  virtual void SendInitialMetadata() = 0;
79 };
80 
82 template <class R>
84  public:
85  virtual ~ReaderInterface() {}
86 
89  virtual bool NextMessageSize(uint32_t* sz) = 0;
90 
101  virtual bool Read(R* msg) = 0;
102 };
103 
105 template <class W>
107  public:
108  virtual ~WriterInterface() {}
109 
117  virtual bool Write(const W& msg, grpc::WriteOptions options) = 0;
118 
125  inline bool Write(const W& msg) { return Write(msg, grpc::WriteOptions()); }
126 
141  void WriteLast(const W& msg, grpc::WriteOptions options) {
142  Write(msg, options.set_last_message());
143  }
144 };
145 
146 } // namespace internal
147 
149 template <class R>
151  public internal::ReaderInterface<R> {
152  public:
157  virtual void WaitForInitialMetadata() = 0;
158 };
159 
160 namespace internal {
161 template <class R>
163  public:
164  template <class W>
166  const grpc::internal::RpcMethod& method,
167  grpc::ClientContext* context,
168  const W& request) {
169  return new ClientReader<R>(channel, method, context, request);
170  }
171 };
172 } // namespace internal
173 
177 template <class R>
178 class ClientReader final : public ClientReaderInterface<R> {
179  public:
183  // Side effect:
187  void WaitForInitialMetadata() override {
188  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
189 
191  ops.RecvInitialMetadata(context_);
192  call_.PerformOps(&ops);
193  cq_.Pluck(&ops);
194  }
195 
196  bool NextMessageSize(uint32_t* sz) override {
197  int result = call_.max_receive_message_size();
198  *sz = (result > 0) ? result : UINT32_MAX;
199  return true;
200  }
201 
207  bool Read(R* msg) override {
210  ops;
211  if (!context_->initial_metadata_received_) {
212  ops.RecvInitialMetadata(context_);
213  }
214  ops.RecvMessage(msg);
215  call_.PerformOps(&ops);
216  return cq_.Pluck(&ops) && ops.got_message;
217  }
218 
224  grpc::Status Finish() override {
227  ops;
228  if (!context_->initial_metadata_received_) {
229  ops.RecvInitialMetadata(context_);
230  }
231  grpc::Status status;
232  ops.ClientRecvStatus(context_, &status);
233  call_.PerformOps(&ops);
234  GPR_CODEGEN_ASSERT(cq_.Pluck(&ops));
235  return status;
236  }
237 
238  private:
240  grpc::ClientContext* context_;
242  grpc::internal::Call call_;
243 
247  template <class W>
249  const grpc::internal::RpcMethod& method,
250  grpc::ClientContext* context, const W& request)
251  : context_(context),
254  nullptr}), // Pluckable cq
255  call_(channel->CreateCall(method, context, &cq_)) {
259  ops;
260  ops.SendInitialMetadata(&context->send_initial_metadata_,
261  context->initial_metadata_flags());
262  // TODO(ctiller): don't assert
263  GPR_CODEGEN_ASSERT(ops.SendMessagePtr(&request).ok());
264  ops.ClientSendClose();
265  call_.PerformOps(&ops);
266  cq_.Pluck(&ops);
267  }
268 };
269 
271 template <class W>
273  public internal::WriterInterface<W> {
274  public:
281  virtual bool WritesDone() = 0;
282 };
283 
284 namespace internal {
285 template <class W>
287  public:
288  template <class R>
290  const grpc::internal::RpcMethod& method,
291  grpc::ClientContext* context, R* response) {
292  return new ClientWriter<W>(channel, method, context, response);
293  }
294 };
295 } // namespace internal
296 
300 template <class W>
301 class ClientWriter : public ClientWriterInterface<W> {
302  public:
306  // Side effect:
310  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
311 
313  ops.RecvInitialMetadata(context_);
314  call_.PerformOps(&ops);
315  cq_.Pluck(&ops); // status ignored
316  }
317 
325  bool Write(const W& msg, grpc::WriteOptions options) override {
329  ops;
330 
331  if (options.is_last_message()) {
332  options.set_buffer_hint();
333  ops.ClientSendClose();
334  }
335  if (context_->initial_metadata_corked_) {
336  ops.SendInitialMetadata(&context_->send_initial_metadata_,
337  context_->initial_metadata_flags());
338  context_->set_initial_metadata_corked(false);
339  }
340  if (!ops.SendMessagePtr(&msg, options).ok()) {
341  return false;
342  }
343 
344  call_.PerformOps(&ops);
345  return cq_.Pluck(&ops);
346  }
347 
348  bool WritesDone() override {
350  ops.ClientSendClose();
351  call_.PerformOps(&ops);
352  return cq_.Pluck(&ops);
353  }
354 
361  grpc::Status Finish() override {
362  grpc::Status status;
363  if (!context_->initial_metadata_received_) {
364  finish_ops_.RecvInitialMetadata(context_);
365  }
366  finish_ops_.ClientRecvStatus(context_, &status);
367  call_.PerformOps(&finish_ops_);
368  GPR_CODEGEN_ASSERT(cq_.Pluck(&finish_ops_));
369  return status;
370  }
371 
372  private:
374 
380  template <class R>
382  const grpc::internal::RpcMethod& method,
383  grpc::ClientContext* context, R* response)
384  : context_(context),
387  nullptr}), // Pluckable cq
388  call_(channel->CreateCall(method, context, &cq_)) {
389  finish_ops_.RecvMessage(response);
390  finish_ops_.AllowNoMessage();
391 
392  if (!context_->initial_metadata_corked_) {
394  ops.SendInitialMetadata(&context->send_initial_metadata_,
395  context->initial_metadata_flags());
396  call_.PerformOps(&ops);
397  cq_.Pluck(&ops);
398  }
399  }
400 
401  grpc::ClientContext* context_;
405  finish_ops_;
407  grpc::internal::Call call_;
408 };
409 
413 template <class W, class R>
415  public internal::WriterInterface<W>,
416  public internal::ReaderInterface<R> {
417  public:
422  virtual void WaitForInitialMetadata() = 0;
423 
430  virtual bool WritesDone() = 0;
431 };
432 
433 namespace internal {
434 template <class W, class R>
436  public:
438  grpc::ChannelInterface* channel, const grpc::internal::RpcMethod& method,
439  grpc::ClientContext* context) {
440  return new ClientReaderWriter<W, R>(channel, method, context);
441  }
442 };
443 } // namespace internal
444 
449 template <class W, class R>
450 class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
451  public:
458  void WaitForInitialMetadata() override {
459  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
460 
462  ops.RecvInitialMetadata(context_);
463  call_.PerformOps(&ops);
464  cq_.Pluck(&ops); // status ignored
465  }
466 
467  bool NextMessageSize(uint32_t* sz) override {
468  int result = call_.max_receive_message_size();
469  *sz = (result > 0) ? result : UINT32_MAX;
470  return true;
471  }
472 
477  bool Read(R* msg) override {
480  ops;
481  if (!context_->initial_metadata_received_) {
482  ops.RecvInitialMetadata(context_);
483  }
484  ops.RecvMessage(msg);
485  call_.PerformOps(&ops);
486  return cq_.Pluck(&ops) && ops.got_message;
487  }
488 
495  bool Write(const W& msg, grpc::WriteOptions options) override {
499  ops;
500 
501  if (options.is_last_message()) {
502  options.set_buffer_hint();
503  ops.ClientSendClose();
504  }
505  if (context_->initial_metadata_corked_) {
506  ops.SendInitialMetadata(&context_->send_initial_metadata_,
507  context_->initial_metadata_flags());
508  context_->set_initial_metadata_corked(false);
509  }
510  if (!ops.SendMessagePtr(&msg, options).ok()) {
511  return false;
512  }
513 
514  call_.PerformOps(&ops);
515  return cq_.Pluck(&ops);
516  }
517 
518  bool WritesDone() override {
520  ops.ClientSendClose();
521  call_.PerformOps(&ops);
522  return cq_.Pluck(&ops);
523  }
524 
530  grpc::Status Finish() override {
533  ops;
534  if (!context_->initial_metadata_received_) {
535  ops.RecvInitialMetadata(context_);
536  }
537  grpc::Status status;
538  ops.ClientRecvStatus(context_, &status);
539  call_.PerformOps(&ops);
540  GPR_CODEGEN_ASSERT(cq_.Pluck(&ops));
541  return status;
542  }
543 
544  private:
546 
547  grpc::ClientContext* context_;
549  grpc::internal::Call call_;
550 
555  const grpc::internal::RpcMethod& method,
556  grpc::ClientContext* context)
557  : context_(context),
560  nullptr}), // Pluckable cq
561  call_(channel->CreateCall(method, context, &cq_)) {
562  if (!context_->initial_metadata_corked_) {
564  ops.SendInitialMetadata(&context->send_initial_metadata_,
565  context->initial_metadata_flags());
566  call_.PerformOps(&ops);
567  cq_.Pluck(&ops);
568  }
569  }
570 };
571 
573 template <class R>
575  public internal::ReaderInterface<R> {};
576 
580 template <class R>
581 class ServerReader final : public ServerReaderInterface<R> {
582  public:
586  void SendInitialMetadata() override {
587  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
588 
590  ops.SendInitialMetadata(&ctx_->initial_metadata_,
591  ctx_->initial_metadata_flags());
592  if (ctx_->compression_level_set()) {
593  ops.set_compression_level(ctx_->compression_level());
594  }
595  ctx_->sent_initial_metadata_ = true;
596  call_->PerformOps(&ops);
597  call_->cq()->Pluck(&ops);
598  }
599 
600  bool NextMessageSize(uint32_t* sz) override {
601  int result = call_->max_receive_message_size();
602  *sz = (result > 0) ? result : UINT32_MAX;
603  return true;
604  }
605 
606  bool Read(R* msg) override {
608  ops.RecvMessage(msg);
609  call_->PerformOps(&ops);
610  bool ok = call_->cq()->Pluck(&ops) && ops.got_message;
611  if (!ok) {
612  ctx_->MaybeMarkCancelledOnRead();
613  }
614  return ok;
615  }
616 
617  private:
618  grpc::internal::Call* const call_;
619  ServerContext* const ctx_;
620 
621  template <class ServiceType, class RequestType, class ResponseType>
623 
625  : call_(call), ctx_(ctx) {}
626 };
627 
629 template <class W>
631  public internal::WriterInterface<W> {};
632 
636 template <class W>
637 class ServerWriter final : public ServerWriterInterface<W> {
638  public:
643  void SendInitialMetadata() override {
644  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
645 
647  ops.SendInitialMetadata(&ctx_->initial_metadata_,
648  ctx_->initial_metadata_flags());
649  if (ctx_->compression_level_set()) {
650  ops.set_compression_level(ctx_->compression_level());
651  }
652  ctx_->sent_initial_metadata_ = true;
653  call_->PerformOps(&ops);
654  call_->cq()->Pluck(&ops);
655  }
656 
663  bool Write(const W& msg, grpc::WriteOptions options) override {
664  if (options.is_last_message()) {
665  options.set_buffer_hint();
666  }
667 
668  if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
669  return false;
670  }
671  if (!ctx_->sent_initial_metadata_) {
672  ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
673  ctx_->initial_metadata_flags());
674  if (ctx_->compression_level_set()) {
675  ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
676  }
677  ctx_->sent_initial_metadata_ = true;
678  }
679  call_->PerformOps(&ctx_->pending_ops_);
680  // if this is the last message we defer the pluck until AFTER we start
681  // the trailing md op. This prevents hangs. See
682  // https://github.com/grpc/grpc/issues/11546
683  if (options.is_last_message()) {
684  ctx_->has_pending_ops_ = true;
685  return true;
686  }
687  ctx_->has_pending_ops_ = false;
688  return call_->cq()->Pluck(&ctx_->pending_ops_);
689  }
690 
691  private:
692  grpc::internal::Call* const call_;
693  grpc::ServerContext* const ctx_;
694 
695  template <class ServiceType, class RequestType, class ResponseType>
697 
699  : call_(call), ctx_(ctx) {}
700 };
701 
703 template <class W, class R>
705  public internal::WriterInterface<W>,
706  public internal::ReaderInterface<R> {};
707 
709 namespace internal {
710 template <class W, class R>
711 class ServerReaderWriterBody final {
712  public:
714  : call_(call), ctx_(ctx) {}
715 
717  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
718 
720  ops.SendInitialMetadata(&ctx_->initial_metadata_,
721  ctx_->initial_metadata_flags());
722  if (ctx_->compression_level_set()) {
723  ops.set_compression_level(ctx_->compression_level());
724  }
725  ctx_->sent_initial_metadata_ = true;
726  call_->PerformOps(&ops);
727  call_->cq()->Pluck(&ops);
728  }
729 
730  bool NextMessageSize(uint32_t* sz) {
731  int result = call_->max_receive_message_size();
732  *sz = (result > 0) ? result : UINT32_MAX;
733  return true;
734  }
735 
736  bool Read(R* msg) {
738  ops.RecvMessage(msg);
739  call_->PerformOps(&ops);
740  bool ok = call_->cq()->Pluck(&ops) && ops.got_message;
741  if (!ok) {
742  ctx_->MaybeMarkCancelledOnRead();
743  }
744  return ok;
745  }
746 
747  bool Write(const W& msg, grpc::WriteOptions options) {
748  if (options.is_last_message()) {
749  options.set_buffer_hint();
750  }
751  if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
752  return false;
753  }
754  if (!ctx_->sent_initial_metadata_) {
755  ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
756  ctx_->initial_metadata_flags());
757  if (ctx_->compression_level_set()) {
758  ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
759  }
760  ctx_->sent_initial_metadata_ = true;
761  }
762  call_->PerformOps(&ctx_->pending_ops_);
763  // if this is the last message we defer the pluck until AFTER we start
764  // the trailing md op. This prevents hangs. See
765  // https://github.com/grpc/grpc/issues/11546
766  if (options.is_last_message()) {
767  ctx_->has_pending_ops_ = true;
768  return true;
769  }
770  ctx_->has_pending_ops_ = false;
771  return call_->cq()->Pluck(&ctx_->pending_ops_);
772  }
773 
774  private:
775  grpc::internal::Call* const call_;
776  grpc::ServerContext* const ctx_;
777 };
778 
779 } // namespace internal
780 
785 template <class W, class R>
787  public:
791  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
792 
793  bool NextMessageSize(uint32_t* sz) override {
794  return body_.NextMessageSize(sz);
795  }
796 
797  bool Read(R* msg) override { return body_.Read(msg); }
798 
805  bool Write(const W& msg, grpc::WriteOptions options) override {
806  return body_.Write(msg, options);
807  }
808 
809  private:
811 
813  false>;
815  : body_(call, ctx) {}
816 };
817 
826 template <class RequestType, class ResponseType>
828  : public ServerReaderWriterInterface<ResponseType, RequestType> {
829  public:
834  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
835 
837  bool NextMessageSize(uint32_t* sz) override {
838  return body_.NextMessageSize(sz);
839  }
840 
851  bool Read(RequestType* request) override {
852  if (read_done_) {
853  return false;
854  }
855  read_done_ = true;
856  return body_.Read(request);
857  }
858 
867  bool Write(const ResponseType& response,
868  grpc::WriteOptions options) override {
869  if (write_done_ || !read_done_) {
870  return false;
871  }
872  write_done_ = true;
873  return body_.Write(response, options);
874  }
875 
876  private:
878  bool read_done_;
879  bool write_done_;
880 
882  ServerUnaryStreamer<RequestType, ResponseType>, true>;
884  : body_(call, ctx), read_done_(false), write_done_(false) {}
885 };
886 
892 template <class RequestType, class ResponseType>
894  : public ServerReaderWriterInterface<ResponseType, RequestType> {
895  public:
900  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
901 
903  bool NextMessageSize(uint32_t* sz) override {
904  return body_.NextMessageSize(sz);
905  }
906 
917  bool Read(RequestType* request) override {
918  if (read_done_) {
919  return false;
920  }
921  read_done_ = true;
922  return body_.Read(request);
923  }
924 
933  bool Write(const ResponseType& response,
934  grpc::WriteOptions options) override {
935  return read_done_ && body_.Write(response, options);
936  }
937 
938  private:
940  bool read_done_;
941 
943  ServerSplitStreamer<RequestType, ResponseType>, false>;
945  : body_(call, ctx), read_done_(false) {}
946 };
947 
948 } // namespace grpc
949 
950 #endif // GRPCPP_IMPL_CODEGEN_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:867
grpc::internal::Call::cq
grpc::CompletionQueue * cq() const
Definition: call.h:72
grpc::internal::CallOpRecvInitialMetadata
Definition: call_op_set.h:728
grpc::internal::ServerReaderWriterBody::ServerReaderWriterBody
ServerReaderWriterBody(grpc::internal::Call *call, grpc::ServerContext *ctx)
Definition: sync_stream.h:713
grpc::ServerWriterInterface
Server-side interface for streaming writes of message of type W.
Definition: sync_stream.h:630
grpc::internal::ServerReaderWriterBody::SendInitialMetadata
void SendInitialMetadata()
Definition: sync_stream.h:716
grpc::internal::CallOpClientSendClose
Definition: call_op_set.h:626
grpc::internal::CallOpGenericRecvMessage
Definition: call_op_set.h:533
grpc::ClientReaderWriter::WritesDone
bool WritesDone() override
Definition: sync_stream.h:518
grpc::ClientWriter
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: channel_interface.h:33
grpc::ServerContext
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:544
grpc::ClientReader::WaitForInitialMetadata
void WaitForInitialMetadata() override
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:187
grpc::internal::Call::max_receive_message_size
int max_receive_message_size() const
Definition: call.h:74
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:289
status.h
grpc::internal::CallOpSendMessage
Definition: call_op_set.h:289
grpc::ClientReaderWriter::Read
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:477
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:158
grpc::internal::WriterInterface::Write
bool Write(const W &msg)
Block to write msg to the stream with default write options.
Definition: sync_stream.h:125
grpc::ServerWriter
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs,...
Definition: completion_queue.h:60
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:933
service_type.h
client_context.h
grpc::internal::ClientReaderFactory
Definition: sync_stream.h:162
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:37
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:224
grpc::ClientReaderWriterInterface
Client-side interface for bi-directional streaming with client-to-server stream messages of type W an...
Definition: sync_stream.h:414
core_codegen_interface.h
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:219
grpc::ClientWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Definition: sync_stream.h:325
grpc::ClientWriter::Finish
grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:361
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:903
grpc::ServerSplitStreamer
A class to represent a flow-controlled server-side streaming call.
Definition: sync_stream.h:893
grpc::internal::ServerReaderWriterBody
Definition: completion_queue.h:63
grpc::internal::ServerStreamingInterface::~ServerStreamingInterface
virtual ~ServerStreamingInterface()
Definition: sync_stream.h:70
grpc::ClientReaderWriter::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Definition: sync_stream.h:467
grpc::ServerReader::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Definition: sync_stream.h:600
grpc::ServerUnaryStreamer::Read
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:851
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:33
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:742
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:238
grpc::ClientReader
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: channel_interface.h:31
grpc::internal::ClientReaderWriterFactory
Definition: sync_stream.h:435
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:231
grpc::internal::WriterInterface
An interface that can be fed a sequence of messages of type W.
Definition: sync_stream.h:106
grpc::ServerReader
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:58
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:805
grpc::ServerWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Definition: sync_stream.h:663
grpc::ServerReaderWriterInterface
Server-side interface for bi-directional streaming.
Definition: sync_stream.h:704
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:272
grpc::ClientReader::Read
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:207
grpc::ChannelInterface
Codegen interface for grpc::Channel.
Definition: channel_interface.h:73
grpc::ClientReader::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Definition: sync_stream.h:196
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:837
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:793
grpc::internal::ServerReaderWriterBody::Write
bool Write(const W &msg, grpc::WriteOptions options)
Definition: sync_stream.h:747
grpc::ClientWriter::WaitForInitialMetadata
void WaitForInitialMetadata()
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:309
GRPC_CQ_PLUCK
@ GRPC_CQ_PLUCK
Events are popped out by calling grpc_completion_queue_pluck() API ONLY.
Definition: grpc_types.h:762
grpc_completion_queue_attributes
Definition: grpc_types.h:790
grpc::internal::ClientStreamingInterface
Common interface for all synchronous client side streaming.
Definition: sync_stream.h:36
grpc::internal::ServerReaderWriterBody::NextMessageSize
bool NextMessageSize(uint32_t *sz)
Definition: sync_stream.h:730
grpc::ServerSplitStreamer::SendInitialMetadata
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:900
grpc::ServerReaderWriter::Read
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream.h:797
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:81
grpc::ServerReaderWriter
Synchronous (blocking) server-side API for a bidirectional streaming call, where the incoming message...
Definition: sync_stream.h:786
grpc::internal::ServerStreamingHandler
A wrapper class of an application provided server streaming handler.
Definition: byte_buffer.h:47
grpc::internal::WriterInterface::~WriterInterface
virtual ~WriterInterface()
Definition: sync_stream.h:108
grpc::ClientReaderWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Definition: sync_stream.h:495
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:165
grpc::ClientReaderWriter::Finish
grpc::Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:530
grpc::internal::ClientStreamingHandler
A wrapper class of an application provided client streaming handler.
Definition: completion_queue.h:73
channel_interface.h
grpc::ClientReaderInterface
Client-side interface for streaming reads of message of type R.
Definition: sync_stream.h:150
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:77
GRPC_CQ_CURRENT_VERSION
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:788
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:586
grpc::internal::Call::PerformOps
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:67
grpc::internal::ServerReaderWriterBody::Read
bool Read(R *msg)
Definition: sync_stream.h:736
grpc::ClientReaderWriter
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: channel_interface.h:35
call.h
grpc::internal::ReaderInterface::~ReaderInterface
virtual ~ReaderInterface()
Definition: sync_stream.h:85
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:246
grpc::ServerReaderInterface
Server-side interface for streaming reads of message of type R.
Definition: sync_stream.h:574
grpc::ClientReaderWriter::WaitForInitialMetadata
void WaitForInitialMetadata() override
Block waiting to read initial metadata from the server.
Definition: sync_stream.h:458
grpc::internal::ClientReaderWriterFactory::Create
static ClientReaderWriter< W, R > * Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context)
Definition: sync_stream.h:437
server_context.h
grpc::internal::CallOpClientRecvStatus
Definition: call_op_set.h:776
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:119
grpc::CompletionQueue
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:104
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:791
grpc::internal::ReaderInterface
An interface that yields a sequence of messages of type R.
Definition: sync_stream.h:83
grpc::ServerWriter::SendInitialMetadata
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:643
grpc::ServerUnaryStreamer
A class to represent a flow-controlled unary call.
Definition: sync_stream.h:827
grpc::ServerUnaryStreamer::SendInitialMetadata
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:834
GPR_CODEGEN_ASSERT
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:149
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:174
grpc::internal::CallOpRecvMessage
Definition: byte_buffer.h:52
completion_queue.h
grpc::internal::RpcMethod
Descriptor of an RPC method.
Definition: rpc_method.h:31
grpc::internal::ClientWriterFactory
Definition: sync_stream.h:286
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:141
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:917
grpc::ClientWriterInterface::WritesDone
virtual bool WritesDone()=0
Half close writing from the client.
grpc::internal::ClientStreamingInterface::~ClientStreamingInterface
virtual ~ClientStreamingInterface()
Definition: sync_stream.h:38
grpc::ClientWriter::WritesDone
bool WritesDone() override
Definition: sync_stream.h:348
grpc::internal::CallOpRecvMessage::RecvMessage
void RecvMessage(R *message)
Definition: call_op_set.h:433
grpc::internal::ServerStreamingInterface
Common interface for all synchronous server side streaming.
Definition: sync_stream.h:68
grpc::ServerReader::Read
bool Read(R *msg) override
Definition: sync_stream.h:606