GRPC C++  1.66.0
async_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_ASYNC_STREAM_H
20 #define GRPCPP_SUPPORT_ASYNC_STREAM_H
21 
22 #include "absl/log/absl_check.h"
23 
24 #include <grpc/grpc.h>
25 #include <grpc/support/log.h>
26 #include <grpcpp/impl/call.h>
29 #include <grpcpp/server_context.h>
30 #include <grpcpp/support/status.h>
31 
32 namespace grpc {
33 
34 namespace internal {
37  public:
39 
43  virtual void StartCall(void* tag) = 0;
44 
51  virtual void ReadInitialMetadata(void* tag) = 0;
52 
80  virtual void Finish(grpc::Status* status, void* tag) = 0;
81 };
82 
84 template <class R>
86  public:
87  virtual ~AsyncReaderInterface() {}
88 
102  virtual void Read(R* msg, void* tag) = 0;
103 };
104 
106 template <class W>
108  public:
110 
123  virtual void Write(const W& msg, void* tag) = 0;
124 
140  virtual void Write(const W& msg, grpc::WriteOptions options, void* tag) = 0;
141 
160  void WriteLast(const W& msg, grpc::WriteOptions options, void* tag) {
161  Write(msg, options.set_last_message(), tag);
162  }
163 };
164 
165 } // namespace internal
166 
167 template <class R>
170  public internal::AsyncReaderInterface<R> {};
171 
172 namespace internal {
173 template <class R>
174 class ClientAsyncReaderFactory {
175  public:
183  template <class W>
186  const grpc::internal::RpcMethod& method,
187  grpc::ClientContext* context,
188  const W& request, bool start, void* tag) {
189  grpc::internal::Call call = channel->CreateCall(method, context, cq);
190  return new (
192  ClientAsyncReader<R>(call, context, request, start, tag);
193  }
194 };
195 } // namespace internal
196 
200 template <class R>
201 class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
202  public:
203  // always allocated against a call arena, no memory free required
204  static void operator delete(void* /*ptr*/, std::size_t size) {
205  ABSL_CHECK_EQ(size, sizeof(ClientAsyncReader));
206  }
207 
208  // This operator should never be called as the memory should be freed as part
209  // of the arena destruction. It only exists to provide a matching operator
210  // delete to the operator new so that some compilers will not complain (see
211  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
212  // there are no tests catching the compiler warning.
213  static void operator delete(void*, void*) { ABSL_CHECK(false); }
214 
215  void StartCall(void* tag) override {
216  ABSL_CHECK(!started_);
217  started_ = true;
218  StartCallInternal(tag);
219  }
220 
229  void ReadInitialMetadata(void* tag) override {
230  ABSL_CHECK(started_);
231  ABSL_CHECK(!context_->initial_metadata_received_);
232 
233  meta_ops_.set_output_tag(tag);
234  meta_ops_.RecvInitialMetadata(context_);
235  call_.PerformOps(&meta_ops_);
236  }
237 
238  void Read(R* msg, void* tag) override {
239  ABSL_CHECK(started_);
240  read_ops_.set_output_tag(tag);
241  if (!context_->initial_metadata_received_) {
242  read_ops_.RecvInitialMetadata(context_);
243  }
244  read_ops_.RecvMessage(msg);
245  call_.PerformOps(&read_ops_);
246  }
247 
253  void Finish(grpc::Status* status, void* tag) override {
254  ABSL_CHECK(started_);
255  finish_ops_.set_output_tag(tag);
256  if (!context_->initial_metadata_received_) {
257  finish_ops_.RecvInitialMetadata(context_);
258  }
259  finish_ops_.ClientRecvStatus(context_, status);
260  call_.PerformOps(&finish_ops_);
261  }
262 
263  private:
265  template <class W>
267  const W& request, bool start, void* tag)
268  : context_(context), call_(call), started_(start) {
269  // TODO(ctiller): don't assert
270  ABSL_CHECK(init_ops_.SendMessage(request).ok());
271  init_ops_.ClientSendClose();
272  if (start) {
273  StartCallInternal(tag);
274  } else {
275  ABSL_CHECK(tag == nullptr);
276  }
277  }
278 
279  void StartCallInternal(void* tag) {
280  init_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
281  context_->initial_metadata_flags());
282  init_ops_.set_output_tag(tag);
283  call_.PerformOps(&init_ops_);
284  }
285 
286  grpc::ClientContext* context_;
287  grpc::internal::Call call_;
288  bool started_;
292  init_ops_;
294  meta_ops_;
297  read_ops_;
300  finish_ops_;
301 };
302 
304 template <class W>
308  public:
313  virtual void WritesDone(void* tag) = 0;
314 };
315 
316 namespace internal {
317 template <class W>
318 class ClientAsyncWriterFactory {
319  public:
331  template <class R>
334  const grpc::internal::RpcMethod& method,
335  grpc::ClientContext* context, R* response,
336  bool start, void* tag) {
337  grpc::internal::Call call = channel->CreateCall(method, context, cq);
338  return new (
340  ClientAsyncWriter<W>(call, context, response, start, tag);
341  }
342 };
343 } // namespace internal
344 
348 template <class W>
349 class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
350  public:
351  // always allocated against a call arena, no memory free required
352  static void operator delete(void* /*ptr*/, std::size_t size) {
353  ABSL_CHECK_EQ(size, sizeof(ClientAsyncWriter));
354  }
355 
356  // This operator should never be called as the memory should be freed as part
357  // of the arena destruction. It only exists to provide a matching operator
358  // delete to the operator new so that some compilers will not complain (see
359  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
360  // there are no tests catching the compiler warning.
361  static void operator delete(void*, void*) { ABSL_CHECK(false); }
362 
363  void StartCall(void* tag) override {
364  ABSL_CHECK(!started_);
365  started_ = true;
366  StartCallInternal(tag);
367  }
368 
376  void ReadInitialMetadata(void* tag) override {
377  ABSL_CHECK(started_);
378  ABSL_CHECK(!context_->initial_metadata_received_);
379 
380  meta_ops_.set_output_tag(tag);
381  meta_ops_.RecvInitialMetadata(context_);
382  call_.PerformOps(&meta_ops_);
383  }
384 
385  void Write(const W& msg, void* tag) override {
386  ABSL_CHECK(started_);
387  write_ops_.set_output_tag(tag);
388  // TODO(ctiller): don't assert
389  ABSL_CHECK(write_ops_.SendMessage(msg).ok());
390  call_.PerformOps(&write_ops_);
391  }
392 
393  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
394  ABSL_CHECK(started_);
395  write_ops_.set_output_tag(tag);
396  if (options.is_last_message()) {
397  options.set_buffer_hint();
398  write_ops_.ClientSendClose();
399  }
400  // TODO(ctiller): don't assert
401  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
402  call_.PerformOps(&write_ops_);
403  }
404 
405  void WritesDone(void* tag) override {
406  ABSL_CHECK(started_);
407  write_ops_.set_output_tag(tag);
408  write_ops_.ClientSendClose();
409  call_.PerformOps(&write_ops_);
410  }
411 
419  void Finish(grpc::Status* status, void* tag) override {
420  ABSL_CHECK(started_);
421  finish_ops_.set_output_tag(tag);
422  if (!context_->initial_metadata_received_) {
423  finish_ops_.RecvInitialMetadata(context_);
424  }
425  finish_ops_.ClientRecvStatus(context_, status);
426  call_.PerformOps(&finish_ops_);
427  }
428 
429  private:
431  template <class R>
433  R* response, bool start, void* tag)
434  : context_(context), call_(call), started_(start) {
435  finish_ops_.RecvMessage(response);
436  finish_ops_.AllowNoMessage();
437  if (start) {
438  StartCallInternal(tag);
439  } else {
440  ABSL_CHECK(tag == nullptr);
441  }
442  }
443 
444  void StartCallInternal(void* tag) {
445  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
446  context_->initial_metadata_flags());
447  // if corked bit is set in context, we just keep the initial metadata
448  // buffered up to coalesce with later message send. No op is performed.
449  if (!context_->initial_metadata_corked_) {
450  write_ops_.set_output_tag(tag);
451  call_.PerformOps(&write_ops_);
452  }
453  }
454 
455  grpc::ClientContext* context_;
456  grpc::internal::Call call_;
457  bool started_;
459  meta_ops_;
463  write_ops_;
467  finish_ops_;
468 };
469 
473 template <class W, class R>
478  public:
483  virtual void WritesDone(void* tag) = 0;
484 };
485 
486 namespace internal {
487 template <class W, class R>
488 class ClientAsyncReaderWriterFactory {
489  public:
499  const grpc::internal::RpcMethod& method, grpc::ClientContext* context,
500  bool start, void* tag) {
501  grpc::internal::Call call = channel->CreateCall(method, context, cq);
502 
503  return new (grpc_call_arena_alloc(call.call(),
505  ClientAsyncReaderWriter<W, R>(call, context, start, tag);
506  }
507 };
508 } // namespace internal
509 
514 template <class W, class R>
515 class ClientAsyncReaderWriter final
516  : public ClientAsyncReaderWriterInterface<W, R> {
517  public:
518  // always allocated against a call arena, no memory free required
519  static void operator delete(void* /*ptr*/, std::size_t size) {
520  ABSL_CHECK_EQ(size, sizeof(ClientAsyncReaderWriter));
521  }
522 
523  // This operator should never be called as the memory should be freed as part
524  // of the arena destruction. It only exists to provide a matching operator
525  // delete to the operator new so that some compilers will not complain (see
526  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
527  // there are no tests catching the compiler warning.
528  static void operator delete(void*, void*) { ABSL_CHECK(false); }
529 
530  void StartCall(void* tag) override {
531  ABSL_CHECK(!started_);
532  started_ = true;
533  StartCallInternal(tag);
534  }
535 
543  void ReadInitialMetadata(void* tag) override {
544  ABSL_CHECK(started_);
545  ABSL_CHECK(!context_->initial_metadata_received_);
546 
547  meta_ops_.set_output_tag(tag);
548  meta_ops_.RecvInitialMetadata(context_);
549  call_.PerformOps(&meta_ops_);
550  }
551 
552  void Read(R* msg, void* tag) override {
553  ABSL_CHECK(started_);
554  read_ops_.set_output_tag(tag);
555  if (!context_->initial_metadata_received_) {
556  read_ops_.RecvInitialMetadata(context_);
557  }
558  read_ops_.RecvMessage(msg);
559  call_.PerformOps(&read_ops_);
560  }
561 
562  void Write(const W& msg, void* tag) override {
563  ABSL_CHECK(started_);
564  write_ops_.set_output_tag(tag);
565  // TODO(ctiller): don't assert
566  ABSL_CHECK(write_ops_.SendMessage(msg).ok());
567  call_.PerformOps(&write_ops_);
568  }
569 
570  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
571  ABSL_CHECK(started_);
572  write_ops_.set_output_tag(tag);
573  if (options.is_last_message()) {
574  options.set_buffer_hint();
575  write_ops_.ClientSendClose();
576  }
577  // TODO(ctiller): don't assert
578  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
579  call_.PerformOps(&write_ops_);
580  }
581 
582  void WritesDone(void* tag) override {
583  ABSL_CHECK(started_);
584  write_ops_.set_output_tag(tag);
585  write_ops_.ClientSendClose();
586  call_.PerformOps(&write_ops_);
587  }
588 
593  void Finish(grpc::Status* status, void* tag) override {
594  ABSL_CHECK(started_);
595  finish_ops_.set_output_tag(tag);
596  if (!context_->initial_metadata_received_) {
597  finish_ops_.RecvInitialMetadata(context_);
598  }
599  finish_ops_.ClientRecvStatus(context_, status);
600  call_.PerformOps(&finish_ops_);
601  }
602 
603  private:
606  grpc::ClientContext* context, bool start, void* tag)
607  : context_(context), call_(call), started_(start) {
608  if (start) {
609  StartCallInternal(tag);
610  } else {
611  ABSL_CHECK(tag == nullptr);
612  }
613  }
614 
615  void StartCallInternal(void* tag) {
616  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
617  context_->initial_metadata_flags());
618  // if corked bit is set in context, we just keep the initial metadata
619  // buffered up to coalesce with later message send. No op is performed.
620  if (!context_->initial_metadata_corked_) {
621  write_ops_.set_output_tag(tag);
622  call_.PerformOps(&write_ops_);
623  }
624  }
625 
626  grpc::ClientContext* context_;
627  grpc::internal::Call call_;
628  bool started_;
630  meta_ops_;
633  read_ops_;
637  write_ops_;
640  finish_ops_;
641 };
642 
643 template <class W, class R>
647  public:
670  virtual void Finish(const W& msg, const grpc::Status& status, void* tag) = 0;
671 
693  virtual void FinishWithError(const grpc::Status& status, void* tag) = 0;
694 };
695 
699 template <class W, class R>
700 class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
701  public:
703  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
704 
710  void SendInitialMetadata(void* tag) override {
711  ABSL_CHECK(!ctx_->sent_initial_metadata_);
712 
713  meta_ops_.set_output_tag(tag);
714  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
715  ctx_->initial_metadata_flags());
716  if (ctx_->compression_level_set()) {
717  meta_ops_.set_compression_level(ctx_->compression_level());
718  }
719  ctx_->sent_initial_metadata_ = true;
720  call_.PerformOps(&meta_ops_);
721  }
722 
723  void Read(R* msg, void* tag) override {
724  read_ops_.set_output_tag(tag);
725  read_ops_.RecvMessage(msg);
726  call_.PerformOps(&read_ops_);
727  }
728 
740  void Finish(const W& msg, const grpc::Status& status, void* tag) override {
741  finish_ops_.set_output_tag(tag);
742  if (!ctx_->sent_initial_metadata_) {
743  finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
744  ctx_->initial_metadata_flags());
745  if (ctx_->compression_level_set()) {
746  finish_ops_.set_compression_level(ctx_->compression_level());
747  }
748  ctx_->sent_initial_metadata_ = true;
749  }
750  // The response is dropped if the status is not OK.
751  if (status.ok()) {
752  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_,
753  finish_ops_.SendMessage(msg));
754  } else {
755  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
756  }
757  call_.PerformOps(&finish_ops_);
758  }
759 
769  void FinishWithError(const grpc::Status& status, void* tag) override {
770  ABSL_CHECK(!status.ok());
771  finish_ops_.set_output_tag(tag);
772  if (!ctx_->sent_initial_metadata_) {
773  finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
774  ctx_->initial_metadata_flags());
775  if (ctx_->compression_level_set()) {
776  finish_ops_.set_compression_level(ctx_->compression_level());
777  }
778  ctx_->sent_initial_metadata_ = true;
779  }
780  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
781  call_.PerformOps(&finish_ops_);
782  }
783 
784  private:
785  void BindCall(grpc::internal::Call* call) override { call_ = *call; }
786 
787  grpc::internal::Call call_;
788  grpc::ServerContext* ctx_;
790  meta_ops_;
795  finish_ops_;
796 };
797 
798 template <class W>
802  public:
824  virtual void Finish(const grpc::Status& status, void* tag) = 0;
825 
840  virtual void WriteAndFinish(const W& msg, grpc::WriteOptions options,
841  const grpc::Status& status, void* tag) = 0;
842 };
843 
846 template <class W>
847 class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
848  public:
850  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
851 
859  void SendInitialMetadata(void* tag) override {
860  ABSL_CHECK(!ctx_->sent_initial_metadata_);
861 
862  meta_ops_.set_output_tag(tag);
863  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
864  ctx_->initial_metadata_flags());
865  if (ctx_->compression_level_set()) {
866  meta_ops_.set_compression_level(ctx_->compression_level());
867  }
868  ctx_->sent_initial_metadata_ = true;
869  call_.PerformOps(&meta_ops_);
870  }
871 
872  void Write(const W& msg, void* tag) override {
873  write_ops_.set_output_tag(tag);
874  EnsureInitialMetadataSent(&write_ops_);
875  // TODO(ctiller): don't assert
876  ABSL_CHECK(write_ops_.SendMessage(msg).ok());
877  call_.PerformOps(&write_ops_);
878  }
879 
880  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
881  write_ops_.set_output_tag(tag);
882  if (options.is_last_message()) {
883  options.set_buffer_hint();
884  }
885 
886  EnsureInitialMetadataSent(&write_ops_);
887  // TODO(ctiller): don't assert
888  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
889  call_.PerformOps(&write_ops_);
890  }
891 
902  void WriteAndFinish(const W& msg, grpc::WriteOptions options,
903  const grpc::Status& status, void* tag) override {
904  write_ops_.set_output_tag(tag);
905  EnsureInitialMetadataSent(&write_ops_);
906  options.set_buffer_hint();
907  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
908  write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
909  call_.PerformOps(&write_ops_);
910  }
911 
923  void Finish(const grpc::Status& status, void* tag) override {
924  finish_ops_.set_output_tag(tag);
925  EnsureInitialMetadataSent(&finish_ops_);
926  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
927  call_.PerformOps(&finish_ops_);
928  }
929 
930  private:
931  void BindCall(grpc::internal::Call* call) override { call_ = *call; }
932 
933  template <class T>
934  void EnsureInitialMetadataSent(T* ops) {
935  if (!ctx_->sent_initial_metadata_) {
936  ops->SendInitialMetadata(&ctx_->initial_metadata_,
937  ctx_->initial_metadata_flags());
938  if (ctx_->compression_level_set()) {
939  ops->set_compression_level(ctx_->compression_level());
940  }
941  ctx_->sent_initial_metadata_ = true;
942  }
943  }
944 
945  grpc::internal::Call call_;
946  grpc::ServerContext* ctx_;
948  meta_ops_;
952  write_ops_;
955  finish_ops_;
956 };
957 
959 template <class W, class R>
964  public:
987  virtual void Finish(const grpc::Status& status, void* tag) = 0;
988 
1003  virtual void WriteAndFinish(const W& msg, grpc::WriteOptions options,
1004  const grpc::Status& status, void* tag) = 0;
1005 };
1006 
1011 template <class W, class R>
1012 class ServerAsyncReaderWriter final
1013  : public ServerAsyncReaderWriterInterface<W, R> {
1014  public:
1016  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
1017 
1025  void SendInitialMetadata(void* tag) override {
1026  ABSL_CHECK(!ctx_->sent_initial_metadata_);
1027 
1028  meta_ops_.set_output_tag(tag);
1029  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
1030  ctx_->initial_metadata_flags());
1031  if (ctx_->compression_level_set()) {
1032  meta_ops_.set_compression_level(ctx_->compression_level());
1033  }
1034  ctx_->sent_initial_metadata_ = true;
1035  call_.PerformOps(&meta_ops_);
1036  }
1037 
1038  void Read(R* msg, void* tag) override {
1039  read_ops_.set_output_tag(tag);
1040  read_ops_.RecvMessage(msg);
1041  call_.PerformOps(&read_ops_);
1042  }
1043 
1044  void Write(const W& msg, void* tag) override {
1045  write_ops_.set_output_tag(tag);
1046  EnsureInitialMetadataSent(&write_ops_);
1047  // TODO(ctiller): don't assert
1048  ABSL_CHECK(write_ops_.SendMessage(msg).ok());
1049  call_.PerformOps(&write_ops_);
1050  }
1051 
1052  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
1053  write_ops_.set_output_tag(tag);
1054  if (options.is_last_message()) {
1055  options.set_buffer_hint();
1056  }
1057  EnsureInitialMetadataSent(&write_ops_);
1058  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
1059  call_.PerformOps(&write_ops_);
1060  }
1061 
1070  //
1073  void WriteAndFinish(const W& msg, grpc::WriteOptions options,
1074  const grpc::Status& status, void* tag) override {
1075  write_ops_.set_output_tag(tag);
1076  EnsureInitialMetadataSent(&write_ops_);
1077  options.set_buffer_hint();
1078  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
1079  write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1080  call_.PerformOps(&write_ops_);
1081  }
1082 
1091  //
1094  void Finish(const grpc::Status& status, void* tag) override {
1095  finish_ops_.set_output_tag(tag);
1096  EnsureInitialMetadataSent(&finish_ops_);
1097 
1098  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1099  call_.PerformOps(&finish_ops_);
1100  }
1101 
1102  private:
1103  friend class grpc::Server;
1104 
1105  void BindCall(grpc::internal::Call* call) override { call_ = *call; }
1106 
1107  template <class T>
1108  void EnsureInitialMetadataSent(T* ops) {
1109  if (!ctx_->sent_initial_metadata_) {
1110  ops->SendInitialMetadata(&ctx_->initial_metadata_,
1111  ctx_->initial_metadata_flags());
1112  if (ctx_->compression_level_set()) {
1113  ops->set_compression_level(ctx_->compression_level());
1114  }
1115  ctx_->sent_initial_metadata_ = true;
1116  }
1117  }
1118 
1119  grpc::internal::Call call_;
1120  grpc::ServerContext* ctx_;
1122  meta_ops_;
1127  write_ops_;
1130  finish_ops_;
1131 };
1132 
1133 } // namespace grpc
1134 
1135 #endif // GRPCPP_SUPPORT_ASYNC_STREAM_H
grpc::internal::CallOpRecvInitialMetadata
Definition: call_op_set.h:723
grpc::ClientAsyncReaderWriter::Finish
void Finish(grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:593
grpc::ServerAsyncReaderWriter::Read
void Read(R *msg, void *tag) override
Definition: async_stream.h:1038
grpc::ClientAsyncWriter::StartCall
void StartCall(void *tag) override
Definition: async_stream.h:363
grpc::internal::ServerAsyncStreamingInterface
Definition: service_type.h:39
grpc::internal::CallOpClientSendClose
Definition: call_op_set.h:621
grpc_call_arena_alloc
GRPCAPI void * grpc_call_arena_alloc(grpc_call *call, size_t size)
Allocate memory in the grpc_call arena: this memory is automatically discarded at call completion.
grpc::internal::CallOpGenericRecvMessage
Definition: call_op_set.h:528
grpc::internal::AsyncWriterInterface
An interface that can be fed a sequence of messages of type W.
Definition: async_stream.h:107
grpc::ServerContext
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:578
grpc::internal::CallOpServerSendStatus
Definition: call_op_set.h:656
grpc::Server
Represents a gRPC server.
Definition: server.h:57
grpc::ClientAsyncReaderWriter::ReadInitialMetadata
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method.
Definition: async_stream.h:543
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
Primary implementation of CallOpSetInterface.
Definition: completion_queue.h:98
grpc::ClientAsyncReaderWriter::Read
void Read(R *msg, void *tag) override
Definition: async_stream.h:552
grpc::internal::ClientAsyncStreamingInterface::~ClientAsyncStreamingInterface
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:38
grpc::internal::CallOpSendMessage
Definition: call_op_set.h:288
grpc::ServerAsyncReaderWriter::Write
void Write(const W &msg, grpc::WriteOptions options, void *tag) override
Definition: async_stream.h:1052
grpc::ClientAsyncWriter::Write
void Write(const W &msg, void *tag) override
Definition: async_stream.h:385
grpc::ServerAsyncWriter
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: server_context.h:58
grpc::internal::ClientAsyncReaderWriterFactory
Definition: channel_interface.h:42
grpc::WriteOptions::set_last_message
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call_op_set.h:157
grpc::ClientAsyncReader::StartCall
void StartCall(void *tag) override
Definition: async_stream.h:215
grpc::ServerAsyncReader::Finish
void Finish(const W &msg, const grpc::Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:740
grpc::ClientAsyncReaderWriterInterface::WritesDone
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
grpc::ServerAsyncWriter::Write
void Write(const W &msg, void *tag) override
Definition: async_stream.h:872
grpc::internal::ClientAsyncWriterFactory::Create
static ClientAsyncWriter< W > * Create(grpc::ChannelInterface *channel, grpc::CompletionQueue *cq, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, R *response, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:332
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:36
grpc::ClientAsyncReaderWriter::WritesDone
void WritesDone(void *tag) override
Definition: async_stream.h:582
grpc::ServerAsyncReader::ServerAsyncReader
ServerAsyncReader(grpc::ServerContext *ctx)
Definition: async_stream.h:702
status.h
grpc::ServerAsyncReaderWriter::WriteAndFinish
void WriteAndFinish(const W &msg, grpc::WriteOptions options, const grpc::Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:1073
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:218
grpc::ServerAsyncReaderInterface::FinishWithError
virtual void FinishWithError(const grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain non-OK status code.
grpc::internal::ClientAsyncStreamingInterface::ReadInitialMetadata
virtual void ReadInitialMetadata(void *tag)=0
Request notification of the reading of the initial metadata.
grpc::internal::ClientAsyncReaderWriterFactory::Create
static ClientAsyncReaderWriter< W, R > * Create(grpc::ChannelInterface *channel, grpc::CompletionQueue *cq, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:497
grpc::ClientAsyncReader::ReadInitialMetadata
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:229
grpc::ClientAsyncWriter::Write
void Write(const W &msg, grpc::WriteOptions options, void *tag) override
Definition: async_stream.h:393
grpc::Status::ok
bool ok() const
Is the status OK?
Definition: status.h:125
grpc::ServerAsyncReaderWriter::Write
void Write(const W &msg, void *tag) override
Definition: async_stream.h:1044
grpc::ServerAsyncReader::Read
void Read(R *msg, void *tag) override
Definition: async_stream.h:723
grpc::ClientAsyncReaderWriterInterface
Async client-side interface for bi-directional streaming, where the client-to-server message stream h...
Definition: async_stream.h:474
grpc::ClientAsyncWriter::Finish
void Finish(grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:419
grpc::ServerAsyncReaderWriter::ServerAsyncReaderWriter
ServerAsyncReaderWriter(grpc::ServerContext *ctx)
Definition: async_stream.h:1015
grpc::ServerAsyncWriterInterface
Definition: async_stream.h:799
grpc::internal::AsyncWriterInterface::WriteLast
void WriteLast(const W &msg, grpc::WriteOptions options, void *tag)
Request the writing of msg and coalesce it with the writing of trailing metadata, using WriteOptions ...
Definition: async_stream.h:160
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:34
grpc::internal::ClientAsyncReaderFactory
Definition: channel_interface.h:38
grpc::ServerAsyncWriterInterface::WriteAndFinish
virtual void WriteAndFinish(const W &msg, grpc::WriteOptions options, const grpc::Status &status, void *tag)=0
Request the writing of msg and coalesce it with trailing metadata which contains status,...
grpc::internal::ClientAsyncStreamingInterface
Common interface for all client side asynchronous streaming.
Definition: async_stream.h:36
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::ServerAsyncReaderWriterInterface::WriteAndFinish
virtual void WriteAndFinish(const W &msg, grpc::WriteOptions options, const grpc::Status &status, void *tag)=0
Request the writing of msg and coalesce it with trailing metadata which contains status,...
grpc::ClientAsyncWriter::WritesDone
void WritesDone(void *tag) override
Definition: async_stream.h:405
grpc::ClientContext
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:195
grpc.h
grpc::ServerAsyncReaderWriterInterface
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:960
grpc::ServerAsyncReaderInterface::Finish
virtual void Finish(const W &msg, const grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code and also send out msg response ...
grpc::ServerAsyncWriter::Write
void Write(const W &msg, grpc::WriteOptions options, void *tag) override
Definition: async_stream.h:880
grpc::ClientAsyncReader
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: client_context.h:87
grpc::ServerAsyncReaderWriter::SendInitialMetadata
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:1025
grpc::ClientAsyncWriterInterface::WritesDone
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
grpc::internal::ClientAsyncStreamingInterface::Finish
virtual void Finish(grpc::Status *status, void *tag)=0
Indicate that the stream is to be finished and request notification for when the call has been ended.
channel_interface.h
grpc::ChannelInterface
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
grpc::ClientAsyncWriter::ReadInitialMetadata
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:376
grpc::ServerAsyncReaderWriter::Finish
void Finish(const grpc::Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream.h:1094
grpc::internal::ClientAsyncStreamingInterface::StartCall
virtual void StartCall(void *tag)=0
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
grpc::internal::ClientAsyncReaderFactory::Create
static ClientAsyncReader< R > * Create(grpc::ChannelInterface *channel, grpc::CompletionQueue *cq, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, const W &request, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:184
grpc::internal::AsyncWriterInterface::Write
virtual void Write(const W &msg, void *tag)=0
Request the writing of msg with identifying tag tag.
grpc::ClientAsyncWriterInterface
Common interface for client side asynchronous writing.
Definition: async_stream.h:305
grpc::ClientAsyncReader::Read
void Read(R *msg, void *tag) override
Definition: async_stream.h:238
grpc::internal::AsyncWriterInterface::~AsyncWriterInterface
virtual ~AsyncWriterInterface()
Definition: async_stream.h:109
grpc::internal::AsyncReaderInterface::Read
virtual void Read(R *msg, void *tag)=0
Read a message of type R into msg.
grpc::ServerAsyncReader::FinishWithError
void FinishWithError(const grpc::Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:769
grpc::ServerAsyncWriter::WriteAndFinish
void WriteAndFinish(const W &msg, grpc::WriteOptions options, const grpc::Status &status, void *tag) override
See the ServerAsyncWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:902
grpc::ClientAsyncWriter
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: client_context.h:89
grpc::internal::CallOpSet::set_output_tag
void set_output_tag(void *return_tag)
Definition: call_op_set.h:939
grpc::WriteOptions
Per-message write options.
Definition: call_op_set.h:80
grpc::ServerAsyncWriterInterface::Finish
virtual void Finish(const grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
grpc::internal::AsyncReaderInterface
An interface that yields a sequence of messages of type R.
Definition: async_stream.h:85
grpc::ClientAsyncReaderWriter
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: client_context.h:91
grpc::ServerAsyncReader::SendInitialMetadata
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:710
grpc::ClientAsyncReaderWriter::Write
void Write(const W &msg, void *tag) override
Definition: async_stream.h:562
grpc::internal::Call::PerformOps
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:66
grpc::ClientAsyncReaderWriter::Write
void Write(const W &msg, grpc::WriteOptions options, void *tag) override
Definition: async_stream.h:570
grpc::internal::Call::call
grpc_call * call() const
Definition: call.h:70
server_context.h
call.h
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::internal::CallOpClientRecvStatus
Definition: call_op_set.h:771
grpc::WriteOptions::set_buffer_hint
WriteOptions & set_buffer_hint()
Sets flag indicating that the write may be buffered and need not go out on the wire immediately.
Definition: call_op_set.h:118
service_type.h
grpc::CompletionQueue
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:105
grpc::internal::ClientAsyncWriterFactory
Definition: channel_interface.h:40
grpc::ClientAsyncReader::Finish
void Finish(grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:253
grpc::internal::AsyncReaderInterface::~AsyncReaderInterface
virtual ~AsyncReaderInterface()
Definition: async_stream.h:87
grpc::ClientAsyncReaderWriter::StartCall
void StartCall(void *tag) override
Definition: async_stream.h:530
grpc::ServerAsyncReaderInterface
Definition: async_stream.h:644
grpc::ServerAsyncWriter::Finish
void Finish(const grpc::Status &status, void *tag) override
See the ServerAsyncWriterInterface.Finish method for semantics.
Definition: async_stream.h:923
grpc::ServerAsyncWriter::SendInitialMetadata
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:859
grpc::WriteOptions::is_last_message
bool is_last_message() const
Get value for the flag indicating that this is the last message, and should be coalesced with trailin...
Definition: call_op_set.h:173
grpc::ServerAsyncReader
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: server_context.h:56
grpc::internal::CallOpRecvMessage
Definition: call_op_set.h:426
grpc::internal::RpcMethod
Descriptor of an RPC method.
Definition: rpc_method.h:29
grpc::ServerAsyncReaderWriter
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: server_context.h:62
grpc::ServerAsyncWriter::ServerAsyncWriter
ServerAsyncWriter(grpc::ServerContext *ctx)
Definition: async_stream.h:849
grpc::ClientAsyncReaderInterface
Definition: async_stream.h:168
grpc::ServerAsyncReaderWriterInterface::Finish
virtual void Finish(const grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.