GRPC C++  1.78.1
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 <grpc/grpc.h>
23 #include <grpcpp/impl/call.h>
26 #include <grpcpp/server_context.h>
27 #include <grpcpp/support/status.h>
28 
29 #include "absl/log/absl_check.h"
30 
31 namespace grpc {
32 
33 namespace internal {
36  public:
38 
46  virtual void StartCall(void* tag) = 0;
47 
54  virtual void ReadInitialMetadata(void* tag) = 0;
55 
83  virtual void Finish(grpc::Status* status, void* tag) = 0;
84 };
85 
87 template <class R>
89  public:
90  virtual ~AsyncReaderInterface() {}
91 
105  virtual void Read(R* msg, void* tag) = 0;
106 };
107 
109 template <class W>
111  public:
113 
126  virtual void Write(const W& msg, void* tag) = 0;
127 
143  virtual void Write(const W& msg, grpc::WriteOptions options, void* tag) = 0;
144 
163  void WriteLast(const W& msg, grpc::WriteOptions options, void* tag) {
164  Write(msg, options.set_last_message(), tag);
165  }
166 };
167 
168 } // namespace internal
169 
170 template <class R>
173  public internal::AsyncReaderInterface<R> {};
174 
175 namespace internal {
176 template <class R>
177 class ClientAsyncReaderFactory {
178  public:
186  template <class W>
189  const grpc::internal::RpcMethod& method,
190  grpc::ClientContext* context,
191  const W& request, bool start, void* tag) {
192  grpc::internal::Call call = channel->CreateCall(method, context, cq);
193  return new (
195  ClientAsyncReader<R>(channel, call, context, request, start, tag);
196  }
197 };
198 } // namespace internal
199 
203 template <class R>
204 class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
205  public:
206  // always allocated against a call arena, no memory free required
207  static void operator delete(void* /*ptr*/, std::size_t size) {
208  ABSL_CHECK_EQ(size, sizeof(ClientAsyncReader));
209  }
210 
211  // This operator should never be called as the memory should be freed as part
212  // of the arena destruction. It only exists to provide a matching operator
213  // delete to the operator new so that some compilers will not complain (see
214  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
215  // there are no tests catching the compiler warning.
216  static void operator delete(void*, void*) { ABSL_CHECK(false); }
217 
218  void StartCall(void* tag) override {
219  ABSL_CHECK(!started_);
220  started_ = true;
221  StartCallInternal(tag);
222  }
223 
232  void ReadInitialMetadata(void* tag) override {
233  ABSL_CHECK(started_);
234  ABSL_CHECK(!context_->initial_metadata_received_);
235 
236  meta_ops_.set_output_tag(tag);
237  meta_ops_.RecvInitialMetadata(context_);
238  call_.PerformOps(&meta_ops_);
239  }
240 
241  void Read(R* msg, void* tag) override {
242  ABSL_CHECK(started_);
243  read_ops_.set_output_tag(tag);
244  if (!context_->initial_metadata_received_) {
245  read_ops_.RecvInitialMetadata(context_);
246  }
247  read_ops_.RecvMessage(msg);
248  call_.PerformOps(&read_ops_);
249  }
250 
256  void Finish(grpc::Status* status, void* tag) override {
257  ABSL_CHECK(started_);
258  finish_ops_.set_output_tag(tag);
259  if (!context_->initial_metadata_received_) {
260  finish_ops_.RecvInitialMetadata(context_);
261  }
262  finish_ops_.ClientRecvStatus(context_, status);
263  call_.PerformOps(&finish_ops_);
264  }
265 
266  private:
268  template <class W>
270  grpc::ClientContext* context, const W& request, bool start,
271  void* tag)
272  : channel_(channel), context_(context), call_(call), started_(start) {
273  // TODO(ctiller): don't assert
274  ABSL_CHECK(
275  init_ops_.SendMessage(request, channel_->memory_allocator()).ok());
276  init_ops_.ClientSendClose();
277  if (start) {
278  StartCallInternal(tag);
279  } else {
280  ABSL_CHECK(tag == nullptr);
281  }
282  }
283 
284  void StartCallInternal(void* tag) {
285  init_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
286  context_->initial_metadata_flags());
287  init_ops_.set_output_tag(tag);
288  call_.PerformOps(&init_ops_);
289  }
290 
291  grpc::ChannelInterface* channel_;
292  grpc::ClientContext* context_;
293  grpc::internal::Call call_;
294  bool started_;
298  init_ops_;
300  meta_ops_;
303  read_ops_;
306  finish_ops_;
307 };
308 
310 template <class W>
314  public:
319  virtual void WritesDone(void* tag) = 0;
320 };
321 
322 namespace internal {
323 template <class W>
324 class ClientAsyncWriterFactory {
325  public:
337  template <class R>
340  const grpc::internal::RpcMethod& method,
341  grpc::ClientContext* context, R* response,
342  bool start, void* tag) {
343  grpc::internal::Call call = channel->CreateCall(method, context, cq);
344  return new (
346  ClientAsyncWriter<W>(channel, call, context, response, start, tag);
347  }
348 };
349 } // namespace internal
350 
354 template <class W>
355 class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
356  public:
357  // always allocated against a call arena, no memory free required
358  static void operator delete(void* /*ptr*/, std::size_t size) {
359  ABSL_CHECK_EQ(size, sizeof(ClientAsyncWriter));
360  }
361 
362  // This operator should never be called as the memory should be freed as part
363  // of the arena destruction. It only exists to provide a matching operator
364  // delete to the operator new so that some compilers will not complain (see
365  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
366  // there are no tests catching the compiler warning.
367  static void operator delete(void*, void*) { ABSL_CHECK(false); }
368 
369  void StartCall(void* tag) override {
370  ABSL_CHECK(!started_);
371  started_ = true;
372  StartCallInternal(tag);
373  }
374 
382  void ReadInitialMetadata(void* tag) override {
383  ABSL_CHECK(started_);
384  ABSL_CHECK(!context_->initial_metadata_received_);
385 
386  meta_ops_.set_output_tag(tag);
387  meta_ops_.RecvInitialMetadata(context_);
388  call_.PerformOps(&meta_ops_);
389  }
390 
391  void Write(const W& msg, void* tag) override {
392  ABSL_CHECK(started_);
393  write_ops_.set_output_tag(tag);
394  // TODO(ctiller): don't assert
395  ABSL_CHECK(write_ops_.SendMessage(msg, channel_->memory_allocator()).ok());
396  call_.PerformOps(&write_ops_);
397  }
398 
399  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
400  ABSL_CHECK(started_);
401  write_ops_.set_output_tag(tag);
402  if (options.is_last_message()) {
403  options.set_buffer_hint();
404  write_ops_.ClientSendClose();
405  }
406 
407  // TODO(ctiller): don't assert
408  ABSL_CHECK(
409  write_ops_.SendMessage(msg, options, channel_->memory_allocator())
410  .ok());
411  call_.PerformOps(&write_ops_);
412  }
413 
414  void WritesDone(void* tag) override {
415  ABSL_CHECK(started_);
416  write_ops_.set_output_tag(tag);
417  write_ops_.ClientSendClose();
418  call_.PerformOps(&write_ops_);
419  }
420 
428  void Finish(grpc::Status* status, void* tag) override {
429  ABSL_CHECK(started_);
430  finish_ops_.set_output_tag(tag);
431  if (!context_->initial_metadata_received_) {
432  finish_ops_.RecvInitialMetadata(context_);
433  }
434  finish_ops_.ClientRecvStatus(context_, status);
435  call_.PerformOps(&finish_ops_);
436  }
437 
438  private:
440  template <class R>
442  grpc::ClientContext* context, R* response, bool start,
443  void* tag)
444  : channel_(channel), context_(context), call_(call), started_(start) {
445  finish_ops_.RecvMessage(response);
446  finish_ops_.AllowNoMessage();
447  if (start) {
448  StartCallInternal(tag);
449  } else {
450  ABSL_CHECK(tag == nullptr);
451  }
452  }
453 
454  void StartCallInternal(void* tag) {
455  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
456  context_->initial_metadata_flags());
457  // if corked bit is set in context, we just keep the initial metadata
458  // buffered up to coalesce with later message send. No op is performed.
459  if (!context_->initial_metadata_corked_) {
460  write_ops_.set_output_tag(tag);
461  call_.PerformOps(&write_ops_);
462  }
463  }
464 
465  grpc::ChannelInterface* channel_;
466  grpc::ClientContext* context_;
467  grpc::internal::Call call_;
468  bool started_;
470  meta_ops_;
474  write_ops_;
478  finish_ops_;
479 };
480 
484 template <class W, class R>
489  public:
494  virtual void WritesDone(void* tag) = 0;
495 };
496 
497 namespace internal {
498 template <class W, class R>
499 class ClientAsyncReaderWriterFactory {
500  public:
510  const grpc::internal::RpcMethod& method, grpc::ClientContext* context,
511  bool start, void* tag) {
512  grpc::internal::Call call = channel->CreateCall(method, context, cq);
513 
514  return new (grpc_call_arena_alloc(call.call(),
516  ClientAsyncReaderWriter<W, R>(channel, call, context, start, tag);
517  }
518 };
519 } // namespace internal
520 
525 template <class W, class R>
526 class ClientAsyncReaderWriter final
527  : public ClientAsyncReaderWriterInterface<W, R> {
528  public:
529  // always allocated against a call arena, no memory free required
530  static void operator delete(void* /*ptr*/, std::size_t size) {
531  ABSL_CHECK_EQ(size, sizeof(ClientAsyncReaderWriter));
532  }
533 
534  // This operator should never be called as the memory should be freed as part
535  // of the arena destruction. It only exists to provide a matching operator
536  // delete to the operator new so that some compilers will not complain (see
537  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
538  // there are no tests catching the compiler warning.
539  static void operator delete(void*, void*) { ABSL_CHECK(false); }
540 
541  void StartCall(void* tag) override {
542  ABSL_CHECK(!started_);
543  started_ = true;
544  StartCallInternal(tag);
545  }
546 
554  void ReadInitialMetadata(void* tag) override {
555  ABSL_CHECK(started_);
556  ABSL_CHECK(!context_->initial_metadata_received_);
557 
558  meta_ops_.set_output_tag(tag);
559  meta_ops_.RecvInitialMetadata(context_);
560  call_.PerformOps(&meta_ops_);
561  }
562 
563  void Read(R* msg, void* tag) override {
564  ABSL_CHECK(started_);
565  read_ops_.set_output_tag(tag);
566  if (!context_->initial_metadata_received_) {
567  read_ops_.RecvInitialMetadata(context_);
568  }
569  read_ops_.RecvMessage(msg);
570  call_.PerformOps(&read_ops_);
571  }
572 
573  void Write(const W& msg, void* tag) override {
574  ABSL_CHECK(started_);
575  write_ops_.set_output_tag(tag);
576  // TODO(ctiller): don't assert
577  ABSL_CHECK(write_ops_.SendMessage(msg, channel_->memory_allocator()).ok());
578  call_.PerformOps(&write_ops_);
579  }
580 
581  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
582  ABSL_CHECK(started_);
583  write_ops_.set_output_tag(tag);
584  if (options.is_last_message()) {
585  options.set_buffer_hint();
586  write_ops_.ClientSendClose();
587  }
588  // TODO(ctiller): don't assert
589  ABSL_CHECK(
590  write_ops_.SendMessage(msg, options, channel_->memory_allocator())
591  .ok());
592  call_.PerformOps(&write_ops_);
593  }
594 
595  void WritesDone(void* tag) override {
596  ABSL_CHECK(started_);
597  write_ops_.set_output_tag(tag);
598  write_ops_.ClientSendClose();
599  call_.PerformOps(&write_ops_);
600  }
601 
606  void Finish(grpc::Status* status, void* tag) override {
607  ABSL_CHECK(started_);
608  finish_ops_.set_output_tag(tag);
609  if (!context_->initial_metadata_received_) {
610  finish_ops_.RecvInitialMetadata(context_);
611  }
612  finish_ops_.ClientRecvStatus(context_, status);
613  call_.PerformOps(&finish_ops_);
614  }
615 
616  private:
620  grpc::ClientContext* context, bool start, void* tag)
621  : channel_(channel), context_(context), call_(call), started_(start) {
622  if (start) {
623  StartCallInternal(tag);
624  } else {
625  ABSL_CHECK(tag == nullptr);
626  }
627  }
628 
629  void StartCallInternal(void* tag) {
630  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
631  context_->initial_metadata_flags());
632  // if corked bit is set in context, we just keep the initial metadata
633  // buffered up to coalesce with later message send. No op is performed.
634  if (!context_->initial_metadata_corked_) {
635  write_ops_.set_output_tag(tag);
636  call_.PerformOps(&write_ops_);
637  }
638  }
639 
640  grpc::ChannelInterface* channel_;
641  grpc::ClientContext* context_;
642  grpc::internal::Call call_;
643  bool started_;
645  meta_ops_;
648  read_ops_;
652  write_ops_;
655  finish_ops_;
656 };
657 
658 template <class W, class R>
662  public:
685  virtual void Finish(const W& msg, const grpc::Status& status, void* tag) = 0;
686 
708  virtual void FinishWithError(const grpc::Status& status, void* tag) = 0;
709 };
710 
714 template <class W, class R>
715 class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
716  public:
718  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
719 
725  void SendInitialMetadata(void* tag) override {
726  ABSL_CHECK(!ctx_->sent_initial_metadata_);
727 
728  meta_ops_.set_output_tag(tag);
729  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
730  ctx_->initial_metadata_flags());
731  if (ctx_->compression_level_set()) {
732  meta_ops_.set_compression_level(ctx_->compression_level());
733  }
734  ctx_->sent_initial_metadata_ = true;
735  call_.PerformOps(&meta_ops_);
736  }
737 
738  void Read(R* msg, void* tag) override {
739  read_ops_.set_output_tag(tag);
740  read_ops_.RecvMessage(msg);
741  call_.PerformOps(&read_ops_);
742  }
743 
755  void Finish(const W& msg, const grpc::Status& status, void* tag) override {
756  finish_ops_.set_output_tag(tag);
757  if (!ctx_->sent_initial_metadata_) {
758  finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
759  ctx_->initial_metadata_flags());
760  if (ctx_->compression_level_set()) {
761  finish_ops_.set_compression_level(ctx_->compression_level());
762  }
763  ctx_->sent_initial_metadata_ = true;
764  }
765  // The response is dropped if the status is not OK.
766  if (status.ok()) {
767  finish_ops_.ServerSendStatus(
768  &ctx_->trailing_metadata_,
769  finish_ops_.SendMessage(msg, ctx_->memory_allocator()));
770  } else {
771  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
772  }
773  call_.PerformOps(&finish_ops_);
774  }
775 
785  void FinishWithError(const grpc::Status& status, void* tag) override {
786  ABSL_CHECK(!status.ok());
787  finish_ops_.set_output_tag(tag);
788  if (!ctx_->sent_initial_metadata_) {
789  finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
790  ctx_->initial_metadata_flags());
791  if (ctx_->compression_level_set()) {
792  finish_ops_.set_compression_level(ctx_->compression_level());
793  }
794  ctx_->sent_initial_metadata_ = true;
795  }
796  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
797  call_.PerformOps(&finish_ops_);
798  }
799 
800  private:
801  void BindCall(grpc::internal::Call* call) override { call_ = *call; }
802 
803  grpc::internal::Call call_;
804  grpc::ServerContext* ctx_;
806  meta_ops_;
811  finish_ops_;
812 };
813 
814 template <class W>
818  public:
840  virtual void Finish(const grpc::Status& status, void* tag) = 0;
841 
856  virtual void WriteAndFinish(const W& msg, grpc::WriteOptions options,
857  const grpc::Status& status, void* tag) = 0;
858 };
859 
862 template <class W>
863 class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
864  public:
866  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
867 
875  void SendInitialMetadata(void* tag) override {
876  ABSL_CHECK(!ctx_->sent_initial_metadata_);
877 
878  meta_ops_.set_output_tag(tag);
879  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
880  ctx_->initial_metadata_flags());
881  if (ctx_->compression_level_set()) {
882  meta_ops_.set_compression_level(ctx_->compression_level());
883  }
884  ctx_->sent_initial_metadata_ = true;
885  call_.PerformOps(&meta_ops_);
886  }
887 
888  void Write(const W& msg, void* tag) override {
889  write_ops_.set_output_tag(tag);
890  EnsureInitialMetadataSent(&write_ops_);
891  // TODO(ctiller): don't assert
892  ABSL_CHECK(write_ops_.SendMessage(msg, ctx_->memory_allocator()).ok());
893  call_.PerformOps(&write_ops_);
894  }
895 
896  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
897  write_ops_.set_output_tag(tag);
898  if (options.is_last_message()) {
899  options.set_buffer_hint();
900  }
901 
902  EnsureInitialMetadataSent(&write_ops_);
903  // TODO(ctiller): don't assert
904  ABSL_CHECK(
905  write_ops_.SendMessage(msg, options, ctx_->memory_allocator()).ok());
906  call_.PerformOps(&write_ops_);
907  }
908 
919  void WriteAndFinish(const W& msg, grpc::WriteOptions options,
920  const grpc::Status& status, void* tag) override {
921  write_ops_.set_output_tag(tag);
922  EnsureInitialMetadataSent(&write_ops_);
923  options.set_buffer_hint();
924  ABSL_CHECK(
925  write_ops_.SendMessage(msg, options, ctx_->memory_allocator()).ok());
926  write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
927  call_.PerformOps(&write_ops_);
928  }
929 
941  void Finish(const grpc::Status& status, void* tag) override {
942  finish_ops_.set_output_tag(tag);
943  EnsureInitialMetadataSent(&finish_ops_);
944  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
945  call_.PerformOps(&finish_ops_);
946  }
947 
948  private:
949  void BindCall(grpc::internal::Call* call) override { call_ = *call; }
950 
951  template <class T>
952  void EnsureInitialMetadataSent(T* ops) {
953  if (!ctx_->sent_initial_metadata_) {
954  ops->SendInitialMetadata(&ctx_->initial_metadata_,
955  ctx_->initial_metadata_flags());
956  if (ctx_->compression_level_set()) {
957  ops->set_compression_level(ctx_->compression_level());
958  }
959  ctx_->sent_initial_metadata_ = true;
960  }
961  }
962 
963  grpc::internal::Call call_;
964  grpc::ServerContext* ctx_;
966  meta_ops_;
970  write_ops_;
973  finish_ops_;
974 };
975 
977 template <class W, class R>
982  public:
1005  virtual void Finish(const grpc::Status& status, void* tag) = 0;
1006 
1021  virtual void WriteAndFinish(const W& msg, grpc::WriteOptions options,
1022  const grpc::Status& status, void* tag) = 0;
1023 };
1024 
1029 template <class W, class R>
1030 class ServerAsyncReaderWriter final
1031  : public ServerAsyncReaderWriterInterface<W, R> {
1032  public:
1034  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
1035 
1043  void SendInitialMetadata(void* tag) override {
1044  ABSL_CHECK(!ctx_->sent_initial_metadata_);
1045 
1046  meta_ops_.set_output_tag(tag);
1047  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
1048  ctx_->initial_metadata_flags());
1049  if (ctx_->compression_level_set()) {
1050  meta_ops_.set_compression_level(ctx_->compression_level());
1051  }
1052  ctx_->sent_initial_metadata_ = true;
1053  call_.PerformOps(&meta_ops_);
1054  }
1055 
1056  void Read(R* msg, void* tag) override {
1057  read_ops_.set_output_tag(tag);
1058  read_ops_.RecvMessage(msg);
1059  call_.PerformOps(&read_ops_);
1060  }
1061 
1062  void Write(const W& msg, void* tag) override {
1063  write_ops_.set_output_tag(tag);
1064  EnsureInitialMetadataSent(&write_ops_);
1065  // TODO(ctiller): don't assert
1066  ABSL_CHECK(write_ops_.SendMessage(msg, ctx_->memory_allocator()).ok());
1067  call_.PerformOps(&write_ops_);
1068  }
1069 
1070  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
1071  write_ops_.set_output_tag(tag);
1072  if (options.is_last_message()) {
1073  options.set_buffer_hint();
1074  }
1075  EnsureInitialMetadataSent(&write_ops_);
1076  ABSL_CHECK(
1077  write_ops_.SendMessage(msg, options, ctx_->memory_allocator()).ok());
1078  call_.PerformOps(&write_ops_);
1079  }
1080 
1089  //
1092  void WriteAndFinish(const W& msg, grpc::WriteOptions options,
1093  const grpc::Status& status, void* tag) override {
1094  write_ops_.set_output_tag(tag);
1095  EnsureInitialMetadataSent(&write_ops_);
1096  options.set_buffer_hint();
1097  ABSL_CHECK(
1098  write_ops_.SendMessage(msg, options, ctx_->memory_allocator()).ok());
1099  write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1100  call_.PerformOps(&write_ops_);
1101  }
1102 
1111  //
1114  void Finish(const grpc::Status& status, void* tag) override {
1115  finish_ops_.set_output_tag(tag);
1116  EnsureInitialMetadataSent(&finish_ops_);
1117 
1118  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1119  call_.PerformOps(&finish_ops_);
1120  }
1121 
1122  private:
1123  friend class grpc::Server;
1124 
1125  void BindCall(grpc::internal::Call* call) override { call_ = *call; }
1126 
1127  template <class T>
1128  void EnsureInitialMetadataSent(T* ops) {
1129  if (!ctx_->sent_initial_metadata_) {
1130  ops->SendInitialMetadata(&ctx_->initial_metadata_,
1131  ctx_->initial_metadata_flags());
1132  if (ctx_->compression_level_set()) {
1133  ops->set_compression_level(ctx_->compression_level());
1134  }
1135  ctx_->sent_initial_metadata_ = true;
1136  }
1137  }
1138 
1139  grpc::internal::Call call_;
1140  grpc::ServerContext* ctx_;
1142  meta_ops_;
1147  write_ops_;
1150  finish_ops_;
1151 };
1152 
1153 } // namespace grpc
1154 
1155 #endif // GRPCPP_SUPPORT_ASYNC_STREAM_H
grpc::internal::CallOpRecvInitialMetadata
Definition: call_op_set.h:725
grpc::ClientAsyncReaderWriter::Finish
void Finish(grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:606
grpc::ServerAsyncReaderWriter::Read
void Read(R *msg, void *tag) override
Definition: async_stream.h:1056
grpc::ClientAsyncWriter::StartCall
void StartCall(void *tag) override
Definition: async_stream.h:369
grpc::internal::ServerAsyncStreamingInterface
Definition: service_type.h:38
grpc::internal::CallOpClientSendClose
Definition: call_op_set.h:623
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:530
grpc::internal::AsyncWriterInterface
An interface that can be fed a sequence of messages of type W.
Definition: async_stream.h:110
grpc::ServerContext
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:586
grpc::internal::CallOpServerSendStatus
Definition: call_op_set.h:658
grpc::Server
Represents a gRPC server.
Definition: server.h:58
grpc::ClientAsyncReaderWriter::ReadInitialMetadata
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method.
Definition: async_stream.h:554
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:97
grpc::ClientAsyncReaderWriter::Read
void Read(R *msg, void *tag) override
Definition: async_stream.h:563
grpc::internal::ClientAsyncStreamingInterface::~ClientAsyncStreamingInterface
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:37
grpc::internal::CallOpSendMessage
Definition: call_op_set.h:289
grpc::ServerAsyncReaderWriter::Write
void Write(const W &msg, grpc::WriteOptions options, void *tag) override
Definition: async_stream.h:1070
grpc::ClientAsyncWriter::Write
void Write(const W &msg, void *tag) override
Definition: async_stream.h:391
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:43
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::ClientAsyncReader::StartCall
void StartCall(void *tag) override
Definition: async_stream.h:218
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:755
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:888
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:338
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:36
grpc::ServerContextBase::memory_allocator
grpc_event_engine::experimental::MemoryAllocator * memory_allocator()
Definition: server_context.h:300
grpc::ClientAsyncReaderWriter::WritesDone
void WritesDone(void *tag) override
Definition: async_stream.h:595
grpc::ServerAsyncReader::ServerAsyncReader
ServerAsyncReader(grpc::ServerContext *ctx)
Definition: async_stream.h:717
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:1092
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:219
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:508
grpc::ClientAsyncReader::ReadInitialMetadata
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:232
grpc::ClientAsyncWriter::Write
void Write(const W &msg, grpc::WriteOptions options, void *tag) override
Definition: async_stream.h:399
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:1062
grpc::ServerAsyncReader::Read
void Read(R *msg, void *tag) override
Definition: async_stream.h:738
grpc::ClientAsyncReaderWriterInterface
Async client-side interface for bi-directional streaming, where the client-to-server message stream h...
Definition: async_stream.h:485
grpc::ClientAsyncWriter::Finish
void Finish(grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:428
grpc::ServerAsyncReaderWriter::ServerAsyncReaderWriter
ServerAsyncReaderWriter(grpc::ServerContext *ctx)
Definition: async_stream.h:1033
grpc::ServerAsyncWriterInterface
Definition: async_stream.h:815
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:163
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:34
grpc::internal::ClientAsyncReaderFactory
Definition: channel_interface.h:39
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:35
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::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:414
grpc::ClientContext
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:194
grpc.h
grpc::ServerAsyncReaderWriterInterface
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:978
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:896
grpc::ClientAsyncReader
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: client_context.h:86
grpc::ServerAsyncReaderWriter::SendInitialMetadata
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:1043
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:72
grpc::ClientAsyncWriter::ReadInitialMetadata
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:382
grpc::ServerAsyncReaderWriter::Finish
void Finish(const grpc::Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream.h:1114
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:187
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:311
grpc::ClientAsyncReader::Read
void Read(R *msg, void *tag) override
Definition: async_stream.h:241
grpc::internal::AsyncWriterInterface::~AsyncWriterInterface
virtual ~AsyncWriterInterface()
Definition: async_stream.h:112
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:785
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:919
grpc::ClientAsyncWriter
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: client_context.h:88
grpc::internal::CallOpSet::set_output_tag
void set_output_tag(void *return_tag)
Definition: call_op_set.h:941
grpc::WriteOptions
Per-message write options.
Definition: call_op_set.h:81
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:88
grpc::ClientAsyncReaderWriter
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: client_context.h:90
grpc::ServerAsyncReader::SendInitialMetadata
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:725
grpc::ClientAsyncReaderWriter::Write
void Write(const W &msg, void *tag) override
Definition: async_stream.h:573
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:581
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: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::ClientAsyncWriterFactory
Definition: channel_interface.h:41
grpc::ClientAsyncReader::Finish
void Finish(grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:256
grpc::internal::AsyncReaderInterface::~AsyncReaderInterface
virtual ~AsyncReaderInterface()
Definition: async_stream.h:90
grpc::ClientAsyncReaderWriter::StartCall
void StartCall(void *tag) override
Definition: async_stream.h:541
grpc::ServerAsyncReaderInterface
Definition: async_stream.h:659
grpc::ServerAsyncWriter::Finish
void Finish(const grpc::Status &status, void *tag) override
See the ServerAsyncWriterInterface.Finish method for semantics.
Definition: async_stream.h:941
grpc::ServerAsyncWriter::SendInitialMetadata
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:875
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::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:429
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:865
grpc::ChannelInterface::memory_allocator
virtual grpc_event_engine::experimental::MemoryAllocator * memory_allocator() const
Definition: channel_interface.h:106
grpc::ClientAsyncReaderInterface
Definition: async_stream.h:171
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.