GRPC C++  1.78.1
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 <grpcpp/client_context.h>
24 #include <grpcpp/impl/call.h>
27 #include <grpcpp/server_context.h>
28 #include <grpcpp/support/status.h>
29 
30 #include "absl/log/absl_check.h"
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  ABSL_CHECK(!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  ABSL_CHECK(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  ABSL_CHECK(ops.SendMessagePtr(&request, channel->memory_allocator()).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  ABSL_CHECK(!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, channel_->memory_allocator()).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  ABSL_CHECK(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  : channel_(channel),
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::ChannelInterface* channel_;
403  grpc::ClientContext* context_;
407  finish_ops_;
409  grpc::internal::Call call_;
410 };
411 
415 template <class W, class R>
417  public internal::WriterInterface<W>,
418  public internal::ReaderInterface<R> {
419  public:
424  virtual void WaitForInitialMetadata() = 0;
425 
432  virtual bool WritesDone() = 0;
433 };
434 
435 namespace internal {
436 template <class W, class R>
438  public:
440  grpc::ChannelInterface* channel, const grpc::internal::RpcMethod& method,
441  grpc::ClientContext* context) {
442  return new ClientReaderWriter<W, R>(channel, method, context);
443  }
444 };
445 } // namespace internal
446 
451 template <class W, class R>
452 class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
453  public:
460  void WaitForInitialMetadata() override {
461  ABSL_CHECK(!context_->initial_metadata_received_);
462 
464  ops.RecvInitialMetadata(context_);
465  call_.PerformOps(&ops);
466  cq_.Pluck(&ops); // status ignored
467  }
468 
469  bool NextMessageSize(uint32_t* sz) override {
470  int result = call_.max_receive_message_size();
471  *sz = (result > 0) ? result : UINT32_MAX;
472  return true;
473  }
474 
479  bool Read(R* msg) override {
482  ops;
483  if (!context_->initial_metadata_received_) {
484  ops.RecvInitialMetadata(context_);
485  }
486  ops.RecvMessage(msg);
487  call_.PerformOps(&ops);
488  return cq_.Pluck(&ops) && ops.got_message;
489  }
490 
497  bool Write(const W& msg, grpc::WriteOptions options) override {
501  ops;
502 
503  if (options.is_last_message()) {
504  options.set_buffer_hint();
505  ops.ClientSendClose();
506  }
507  if (context_->initial_metadata_corked_) {
508  ops.SendInitialMetadata(&context_->send_initial_metadata_,
509  context_->initial_metadata_flags());
510  context_->set_initial_metadata_corked(false);
511  }
512  if (!ops.SendMessagePtr(&msg, options, channel_->memory_allocator()).ok()) {
513  return false;
514  }
515 
516  call_.PerformOps(&ops);
517  return cq_.Pluck(&ops);
518  }
519 
520  bool WritesDone() override {
522  ops.ClientSendClose();
523  call_.PerformOps(&ops);
524  return cq_.Pluck(&ops);
525  }
526 
532  grpc::Status Finish() override {
535  ops;
536  if (!context_->initial_metadata_received_) {
537  ops.RecvInitialMetadata(context_);
538  }
539  grpc::Status status;
540  ops.ClientRecvStatus(context_, &status);
541  call_.PerformOps(&ops);
542  ABSL_CHECK(cq_.Pluck(&ops));
543  return status;
544  }
545 
546  private:
548 
549  grpc::ChannelInterface* channel_;
550  grpc::ClientContext* context_;
552  grpc::internal::Call call_;
553 
558  const grpc::internal::RpcMethod& method,
559  grpc::ClientContext* context)
560  : channel_(channel),
561  context_(context),
564  nullptr}), // Pluckable cq
565  call_(channel->CreateCall(method, context, &cq_)) {
566  if (!context_->initial_metadata_corked_) {
568  ops.SendInitialMetadata(&context->send_initial_metadata_,
569  context->initial_metadata_flags());
570  call_.PerformOps(&ops);
571  cq_.Pluck(&ops);
572  }
573  }
574 };
575 
577 template <class R>
579  public internal::ReaderInterface<R> {};
580 
584 template <class R>
585 class ServerReader final : public ServerReaderInterface<R> {
586  public:
590  void SendInitialMetadata() override {
591  ABSL_CHECK(!ctx_->sent_initial_metadata_);
592 
594  ops.SendInitialMetadata(&ctx_->initial_metadata_,
595  ctx_->initial_metadata_flags());
596  if (ctx_->compression_level_set()) {
597  ops.set_compression_level(ctx_->compression_level());
598  }
599  ctx_->sent_initial_metadata_ = true;
600  call_->PerformOps(&ops);
601  call_->cq()->Pluck(&ops);
602  }
603 
604  bool NextMessageSize(uint32_t* sz) override {
605  int result = call_->max_receive_message_size();
606  *sz = (result > 0) ? result : UINT32_MAX;
607  return true;
608  }
609 
610  bool Read(R* msg) override {
612  ops.RecvMessage(msg);
613  call_->PerformOps(&ops);
614  bool ok = call_->cq()->Pluck(&ops) && ops.got_message;
615  if (!ok) {
616  ctx_->MaybeMarkCancelledOnRead();
617  }
618  return ok;
619  }
620 
621  private:
622  grpc::internal::Call* const call_;
623  ServerContext* const ctx_;
624 
625  template <class ServiceType, class RequestType, class ResponseType>
627 
629  : call_(call), ctx_(ctx) {}
630 };
631 
633 template <class W>
635  public internal::WriterInterface<W> {};
636 
640 template <class W>
641 class ServerWriter final : public ServerWriterInterface<W> {
642  public:
647  void SendInitialMetadata() override {
648  ABSL_CHECK(!ctx_->sent_initial_metadata_);
649 
651  ops.SendInitialMetadata(&ctx_->initial_metadata_,
652  ctx_->initial_metadata_flags());
653  if (ctx_->compression_level_set()) {
654  ops.set_compression_level(ctx_->compression_level());
655  }
656  ctx_->sent_initial_metadata_ = true;
657  call_->PerformOps(&ops);
658  call_->cq()->Pluck(&ops);
659  }
660 
667  bool Write(const W& msg, grpc::WriteOptions options) override {
668  if (options.is_last_message()) {
669  options.set_buffer_hint();
670  }
671 
672  if (!ctx_->pending_ops_
673  .SendMessagePtr(&msg, options, ctx_->memory_allocator())
674  .ok()) {
675  return false;
676  }
677  if (!ctx_->sent_initial_metadata_) {
678  ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
679  ctx_->initial_metadata_flags());
680  if (ctx_->compression_level_set()) {
681  ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
682  }
683  ctx_->sent_initial_metadata_ = true;
684  }
685  call_->PerformOps(&ctx_->pending_ops_);
686  // if this is the last message we defer the pluck until AFTER we start
687  // the trailing md op. This prevents hangs. See
688  // https://github.com/grpc/grpc/issues/11546
689  if (options.is_last_message()) {
690  ctx_->has_pending_ops_ = true;
691  return true;
692  }
693  ctx_->has_pending_ops_ = false;
694  return call_->cq()->Pluck(&ctx_->pending_ops_);
695  }
696 
697  private:
698  grpc::internal::Call* const call_;
699  grpc::ServerContext* const ctx_;
700 
701  template <class ServiceType, class RequestType, class ResponseType>
703 
705  : call_(call), ctx_(ctx) {}
706 };
707 
709 template <class W, class R>
711  public internal::WriterInterface<W>,
712  public internal::ReaderInterface<R> {};
713 
715 namespace internal {
716 template <class W, class R>
717 class ServerReaderWriterBody final {
718  public:
720  : call_(call), ctx_(ctx) {}
721 
723  ABSL_CHECK(!ctx_->sent_initial_metadata_);
724 
726  ops.SendInitialMetadata(&ctx_->initial_metadata_,
727  ctx_->initial_metadata_flags());
728  if (ctx_->compression_level_set()) {
729  ops.set_compression_level(ctx_->compression_level());
730  }
731  ctx_->sent_initial_metadata_ = true;
732  call_->PerformOps(&ops);
733  call_->cq()->Pluck(&ops);
734  }
735 
736  bool NextMessageSize(uint32_t* sz) {
737  int result = call_->max_receive_message_size();
738  *sz = (result > 0) ? result : UINT32_MAX;
739  return true;
740  }
741 
742  bool Read(R* msg) {
744  ops.RecvMessage(msg);
745  call_->PerformOps(&ops);
746  bool ok = call_->cq()->Pluck(&ops) && ops.got_message;
747  if (!ok) {
748  ctx_->MaybeMarkCancelledOnRead();
749  }
750  return ok;
751  }
752 
753  bool Write(const W& msg, grpc::WriteOptions options) {
754  if (options.is_last_message()) {
755  options.set_buffer_hint();
756  }
757  if (!ctx_->pending_ops_
758  .SendMessagePtr(&msg, options, ctx_->memory_allocator())
759  .ok()) {
760  return false;
761  }
762  if (!ctx_->sent_initial_metadata_) {
763  ctx_->pending_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
764  ctx_->initial_metadata_flags());
765  if (ctx_->compression_level_set()) {
766  ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
767  }
768  ctx_->sent_initial_metadata_ = true;
769  }
770  call_->PerformOps(&ctx_->pending_ops_);
771  // if this is the last message we defer the pluck until AFTER we start
772  // the trailing md op. This prevents hangs. See
773  // https://github.com/grpc/grpc/issues/11546
774  if (options.is_last_message()) {
775  ctx_->has_pending_ops_ = true;
776  return true;
777  }
778  ctx_->has_pending_ops_ = false;
779  return call_->cq()->Pluck(&ctx_->pending_ops_);
780  }
781 
782  private:
783  grpc::internal::Call* const call_;
784  grpc::ServerContext* const ctx_;
785 };
786 
787 } // namespace internal
788 
793 template <class W, class R>
795  public:
799  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
800 
801  bool NextMessageSize(uint32_t* sz) override {
802  return body_.NextMessageSize(sz);
803  }
804 
805  bool Read(R* msg) override { return body_.Read(msg); }
806 
813  bool Write(const W& msg, grpc::WriteOptions options) override {
814  return body_.Write(msg, options);
815  }
816 
817  private:
819 
821  false>;
823  : body_(call, ctx) {}
824 };
825 
834 template <class RequestType, class ResponseType>
836  : public ServerReaderWriterInterface<ResponseType, RequestType> {
837  public:
842  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
843 
845  bool NextMessageSize(uint32_t* sz) override {
846  return body_.NextMessageSize(sz);
847  }
848 
859  bool Read(RequestType* request) override {
860  if (read_done_) {
861  return false;
862  }
863  read_done_ = true;
864  return body_.Read(request);
865  }
866 
875  bool Write(const ResponseType& response,
876  grpc::WriteOptions options) override {
877  if (write_done_ || !read_done_) {
878  return false;
879  }
880  write_done_ = true;
881  return body_.Write(response, options);
882  }
883 
884  private:
886  bool read_done_;
887  bool write_done_;
888 
890  ServerUnaryStreamer<RequestType, ResponseType>, true>;
892  : body_(call, ctx), read_done_(false), write_done_(false) {}
893 };
894 
900 template <class RequestType, class ResponseType>
902  : public ServerReaderWriterInterface<ResponseType, RequestType> {
903  public:
908  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
909 
911  bool NextMessageSize(uint32_t* sz) override {
912  return body_.NextMessageSize(sz);
913  }
914 
925  bool Read(RequestType* request) override {
926  if (read_done_) {
927  return false;
928  }
929  read_done_ = true;
930  return body_.Read(request);
931  }
932 
941  bool Write(const ResponseType& response,
942  grpc::WriteOptions options) override {
943  return read_done_ && body_.Write(response, options);
944  }
945 
946  private:
948  bool read_done_;
949 
951  ServerSplitStreamer<RequestType, ResponseType>, false>;
953  : body_(call, ctx), read_done_(false) {}
954 };
955 
956 } // namespace grpc
957 
958 #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:875
grpc::internal::Call::cq
grpc::CompletionQueue * cq() const
Definition: call.h:71
grpc::internal::CallOpRecvInitialMetadata
Definition: call_op_set.h:725
grpc::internal::ServerReaderWriterBody::ServerReaderWriterBody
ServerReaderWriterBody(grpc::internal::Call *call, grpc::ServerContext *ctx)
Definition: sync_stream.h:719
grpc::ServerWriterInterface
Server-side interface for streaming writes of message of type W.
Definition: sync_stream.h:634
grpc::internal::ServerReaderWriterBody::SendInitialMetadata
void SendInitialMetadata()
Definition: sync_stream.h:722
grpc::internal::CallOpClientSendClose
Definition: call_op_set.h:623
grpc::internal::CallOpGenericRecvMessage
Definition: call_op_set.h:530
grpc::ClientReaderWriter::WritesDone
bool WritesDone() override
Definition: sync_stream.h:520
grpc::ClientWriter
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: client_context.h:82
grpc::ServerContext
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:586
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: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:289
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:479
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:62
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:941
grpc::internal::ClientReaderFactory
Definition: sync_stream.h:162
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:224
grpc::ClientReaderWriterInterface
Client-side interface for bi-directional streaming with client-to-server stream messages of type W an...
Definition: sync_stream.h:416
grpc::ServerContextBase::memory_allocator
grpc_event_engine::experimental::MemoryAllocator * memory_allocator()
Definition: server_context.h:300
status.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:911
grpc::ServerSplitStreamer
A class to represent a flow-controlled server-side streaming call.
Definition: sync_stream.h:901
grpc::internal::ServerReaderWriterBody
Definition: completion_queue.h:65
grpc::internal::ServerStreamingInterface::~ServerStreamingInterface
virtual ~ServerStreamingInterface()
Definition: sync_stream.h:70
grpc::ClientReaderWriter::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Definition: sync_stream.h:469
grpc::ServerReader::NextMessageSize
bool NextMessageSize(uint32_t *sz) override
Definition: sync_stream.h:604
grpc::ServerUnaryStreamer::Read
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:859
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:413
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:80
grpc::internal::ClientReaderWriterFactory
Definition: sync_stream.h:437
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
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:60
completion_queue.h
grpc::ClientContext
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:194
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:813
grpc::ServerWriter::Write
bool Write(const W &msg, grpc::WriteOptions options) override
Definition: sync_stream.h:667
grpc::ServerReaderWriterInterface
Server-side interface for bi-directional streaming.
Definition: sync_stream.h:710
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:72
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:845
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:801
grpc::internal::ServerReaderWriterBody::Write
bool Write(const W &msg, grpc::WriteOptions options)
Definition: sync_stream.h:753
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:433
grpc_completion_queue_attributes
Definition: grpc_types.h:461
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:736
grpc::ServerSplitStreamer::SendInitialMetadata
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:908
grpc::ServerReaderWriter::Read
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream.h:805
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:794
client_context.h
grpc::internal::ServerStreamingHandler
A wrapper class of an application provided server streaming handler.
Definition: completion_queue.h:77
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:497
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:532
grpc::internal::ClientStreamingHandler
A wrapper class of an application provided client streaming handler.
Definition: completion_queue.h:75
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:79
GRPC_CQ_CURRENT_VERSION
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:459
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:590
grpc::internal::Call::PerformOps
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:66
grpc::internal::ServerReaderWriterBody::Read
bool Read(R *msg)
Definition: sync_stream.h:742
grpc::ClientReaderWriter
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: client_context.h:84
server_context.h
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:251
grpc::ServerReaderInterface
Server-side interface for streaming reads of message of type R.
Definition: sync_stream.h:578
grpc::ClientReaderWriter::WaitForInitialMetadata
void WaitForInitialMetadata() override
Block waiting to read initial metadata from the server.
Definition: sync_stream.h:460
grpc::internal::ClientReaderWriterFactory::Create
static ClientReaderWriter< W, R > * Create(grpc::ChannelInterface *channel, const grpc::internal::RpcMethod &method, grpc::ClientContext *context)
Definition: sync_stream.h:439
grpc::internal::CallOpClientRecvStatus
Definition: call_op_set.h:773
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
service_type.h
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:799
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:647
grpc::ServerUnaryStreamer
A class to represent a flow-controlled unary call.
Definition: sync_stream.h:835
grpc::ServerUnaryStreamer::SendInitialMetadata
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:842
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: call_op_set.h:429
grpc::internal::RpcMethod
Descriptor of an RPC method.
Definition: rpc_method.h:29
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:925
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::ChannelInterface::memory_allocator
virtual grpc_event_engine::experimental::MemoryAllocator * memory_allocator() const
Definition: channel_interface.h:106
grpc::internal::CallOpRecvMessage::RecvMessage
void RecvMessage(R *message)
Definition: call_op_set.h:431
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:610