GRPC C++  1.39.1
async_stream.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2019 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
19 #define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
20 
27 
28 namespace grpc {
29 
30 namespace internal {
33  public:
35 
39  virtual void StartCall(void* tag) = 0;
40 
47  virtual void ReadInitialMetadata(void* tag) = 0;
48 
76  virtual void Finish(::grpc::Status* status, void* tag) = 0;
77 };
78 
80 template <class R>
82  public:
83  virtual ~AsyncReaderInterface() {}
84 
98  virtual void Read(R* msg, void* tag) = 0;
99 };
100 
102 template <class W>
104  public:
106 
119  virtual void Write(const W& msg, void* tag) = 0;
120 
136  virtual void Write(const W& msg, ::grpc::WriteOptions options, void* tag) = 0;
137 
156  void WriteLast(const W& msg, ::grpc::WriteOptions options, void* tag) {
157  Write(msg, options.set_last_message(), tag);
158  }
159 };
160 
161 } // namespace internal
162 
163 template <class R>
166  public internal::AsyncReaderInterface<R> {};
167 
168 namespace internal {
169 template <class R>
171  public:
179  template <class W>
181  ::grpc::CompletionQueue* cq,
182  const ::grpc::internal::RpcMethod& method,
183  ::grpc::ClientContext* context,
184  const W& request, bool start, void* tag) {
185  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
187  call.call(), sizeof(ClientAsyncReader<R>)))
188  ClientAsyncReader<R>(call, context, request, start, tag);
189  }
190 };
191 } // namespace internal
192 
196 template <class R>
198  public:
199  // always allocated against a call arena, no memory free required
200  static void operator delete(void* /*ptr*/, std::size_t size) {
201  GPR_CODEGEN_ASSERT(size == sizeof(ClientAsyncReader));
202  }
203 
204  // This operator should never be called as the memory should be freed as part
205  // of the arena destruction. It only exists to provide a matching operator
206  // delete to the operator new so that some compilers will not complain (see
207  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
208  // there are no tests catching the compiler warning.
209  static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
210 
211  void StartCall(void* tag) override {
212  GPR_CODEGEN_ASSERT(!started_);
213  started_ = true;
214  StartCallInternal(tag);
215  }
216 
225  void ReadInitialMetadata(void* tag) override {
226  GPR_CODEGEN_ASSERT(started_);
227  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
228 
229  meta_ops_.set_output_tag(tag);
230  meta_ops_.RecvInitialMetadata(context_);
231  call_.PerformOps(&meta_ops_);
232  }
233 
234  void Read(R* msg, void* tag) override {
235  GPR_CODEGEN_ASSERT(started_);
236  read_ops_.set_output_tag(tag);
237  if (!context_->initial_metadata_received_) {
238  read_ops_.RecvInitialMetadata(context_);
239  }
240  read_ops_.RecvMessage(msg);
241  call_.PerformOps(&read_ops_);
242  }
243 
249  void Finish(::grpc::Status* status, void* tag) override {
250  GPR_CODEGEN_ASSERT(started_);
251  finish_ops_.set_output_tag(tag);
252  if (!context_->initial_metadata_received_) {
253  finish_ops_.RecvInitialMetadata(context_);
254  }
255  finish_ops_.ClientRecvStatus(context_, status);
256  call_.PerformOps(&finish_ops_);
257  }
258 
259  private:
260  friend class internal::ClientAsyncReaderFactory<R>;
261  template <class W>
263  const W& request, bool start, void* tag)
264  : context_(context), call_(call), started_(start) {
265  // TODO(ctiller): don't assert
266  GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok());
267  init_ops_.ClientSendClose();
268  if (start) {
269  StartCallInternal(tag);
270  } else {
271  GPR_CODEGEN_ASSERT(tag == nullptr);
272  }
273  }
274 
275  void StartCallInternal(void* tag) {
276  init_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
277  context_->initial_metadata_flags());
278  init_ops_.set_output_tag(tag);
279  call_.PerformOps(&init_ops_);
280  }
281 
282  ::grpc::ClientContext* context_;
284  bool started_;
288  init_ops_;
290  meta_ops_;
293  read_ops_;
296  finish_ops_;
297 };
298 
300 template <class W>
304  public:
309  virtual void WritesDone(void* tag) = 0;
310 };
311 
312 namespace internal {
313 template <class W>
315  public:
327  template <class R>
329  ::grpc::CompletionQueue* cq,
330  const ::grpc::internal::RpcMethod& method,
331  ::grpc::ClientContext* context,
332  R* response, bool start, void* tag) {
333  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
335  call.call(), sizeof(ClientAsyncWriter<W>)))
336  ClientAsyncWriter<W>(call, context, response, start, tag);
337  }
338 };
339 } // namespace internal
340 
344 template <class W>
346  public:
347  // always allocated against a call arena, no memory free required
348  static void operator delete(void* /*ptr*/, std::size_t size) {
349  GPR_CODEGEN_ASSERT(size == sizeof(ClientAsyncWriter));
350  }
351 
352  // This operator should never be called as the memory should be freed as part
353  // of the arena destruction. It only exists to provide a matching operator
354  // delete to the operator new so that some compilers will not complain (see
355  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
356  // there are no tests catching the compiler warning.
357  static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
358 
359  void StartCall(void* tag) override {
360  GPR_CODEGEN_ASSERT(!started_);
361  started_ = true;
362  StartCallInternal(tag);
363  }
364 
372  void ReadInitialMetadata(void* tag) override {
373  GPR_CODEGEN_ASSERT(started_);
374  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
375 
376  meta_ops_.set_output_tag(tag);
377  meta_ops_.RecvInitialMetadata(context_);
378  call_.PerformOps(&meta_ops_);
379  }
380 
381  void Write(const W& msg, void* tag) override {
382  GPR_CODEGEN_ASSERT(started_);
383  write_ops_.set_output_tag(tag);
384  // TODO(ctiller): don't assert
385  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
386  call_.PerformOps(&write_ops_);
387  }
388 
389  void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override {
390  GPR_CODEGEN_ASSERT(started_);
391  write_ops_.set_output_tag(tag);
392  if (options.is_last_message()) {
393  options.set_buffer_hint();
394  write_ops_.ClientSendClose();
395  }
396  // TODO(ctiller): don't assert
397  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
398  call_.PerformOps(&write_ops_);
399  }
400 
401  void WritesDone(void* tag) override {
402  GPR_CODEGEN_ASSERT(started_);
403  write_ops_.set_output_tag(tag);
404  write_ops_.ClientSendClose();
405  call_.PerformOps(&write_ops_);
406  }
407 
415  void Finish(::grpc::Status* status, void* tag) override {
416  GPR_CODEGEN_ASSERT(started_);
417  finish_ops_.set_output_tag(tag);
418  if (!context_->initial_metadata_received_) {
419  finish_ops_.RecvInitialMetadata(context_);
420  }
421  finish_ops_.ClientRecvStatus(context_, status);
422  call_.PerformOps(&finish_ops_);
423  }
424 
425  private:
426  friend class internal::ClientAsyncWriterFactory<W>;
427  template <class R>
429  R* response, bool start, void* tag)
430  : context_(context), call_(call), started_(start) {
431  finish_ops_.RecvMessage(response);
432  finish_ops_.AllowNoMessage();
433  if (start) {
434  StartCallInternal(tag);
435  } else {
436  GPR_CODEGEN_ASSERT(tag == nullptr);
437  }
438  }
439 
440  void StartCallInternal(void* tag) {
441  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
442  context_->initial_metadata_flags());
443  // if corked bit is set in context, we just keep the initial metadata
444  // buffered up to coalesce with later message send. No op is performed.
445  if (!context_->initial_metadata_corked_) {
446  write_ops_.set_output_tag(tag);
447  call_.PerformOps(&write_ops_);
448  }
449  }
450 
451  ::grpc::ClientContext* context_;
453  bool started_;
455  meta_ops_;
459  write_ops_;
463  finish_ops_;
464 };
465 
469 template <class W, class R>
474  public:
479  virtual void WritesDone(void* tag) = 0;
480 };
481 
482 namespace internal {
483 template <class W, class R>
485  public:
495  const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context,
496  bool start, void* tag) {
497  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
498 
500  call.call(), sizeof(ClientAsyncReaderWriter<W, R>)))
501  ClientAsyncReaderWriter<W, R>(call, context, start, tag);
502  }
503 };
504 } // namespace internal
505 
510 template <class W, class R>
512  : public ClientAsyncReaderWriterInterface<W, R> {
513  public:
514  // always allocated against a call arena, no memory free required
515  static void operator delete(void* /*ptr*/, std::size_t size) {
517  }
518 
519  // This operator should never be called as the memory should be freed as part
520  // of the arena destruction. It only exists to provide a matching operator
521  // delete to the operator new so that some compilers will not complain (see
522  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
523  // there are no tests catching the compiler warning.
524  static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); }
525 
526  void StartCall(void* tag) override {
527  GPR_CODEGEN_ASSERT(!started_);
528  started_ = true;
529  StartCallInternal(tag);
530  }
531 
539  void ReadInitialMetadata(void* tag) override {
540  GPR_CODEGEN_ASSERT(started_);
541  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
542 
543  meta_ops_.set_output_tag(tag);
544  meta_ops_.RecvInitialMetadata(context_);
545  call_.PerformOps(&meta_ops_);
546  }
547 
548  void Read(R* msg, void* tag) override {
549  GPR_CODEGEN_ASSERT(started_);
550  read_ops_.set_output_tag(tag);
551  if (!context_->initial_metadata_received_) {
552  read_ops_.RecvInitialMetadata(context_);
553  }
554  read_ops_.RecvMessage(msg);
555  call_.PerformOps(&read_ops_);
556  }
557 
558  void Write(const W& msg, void* tag) override {
559  GPR_CODEGEN_ASSERT(started_);
560  write_ops_.set_output_tag(tag);
561  // TODO(ctiller): don't assert
562  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
563  call_.PerformOps(&write_ops_);
564  }
565 
566  void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override {
567  GPR_CODEGEN_ASSERT(started_);
568  write_ops_.set_output_tag(tag);
569  if (options.is_last_message()) {
570  options.set_buffer_hint();
571  write_ops_.ClientSendClose();
572  }
573  // TODO(ctiller): don't assert
574  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
575  call_.PerformOps(&write_ops_);
576  }
577 
578  void WritesDone(void* tag) override {
579  GPR_CODEGEN_ASSERT(started_);
580  write_ops_.set_output_tag(tag);
581  write_ops_.ClientSendClose();
582  call_.PerformOps(&write_ops_);
583  }
584 
589  void Finish(::grpc::Status* status, void* tag) override {
590  GPR_CODEGEN_ASSERT(started_);
591  finish_ops_.set_output_tag(tag);
592  if (!context_->initial_metadata_received_) {
593  finish_ops_.RecvInitialMetadata(context_);
594  }
595  finish_ops_.ClientRecvStatus(context_, status);
596  call_.PerformOps(&finish_ops_);
597  }
598 
599  private:
600  friend class internal::ClientAsyncReaderWriterFactory<W, R>;
602  ::grpc::ClientContext* context, bool start, void* tag)
603  : context_(context), call_(call), started_(start) {
604  if (start) {
605  StartCallInternal(tag);
606  } else {
607  GPR_CODEGEN_ASSERT(tag == nullptr);
608  }
609  }
610 
611  void StartCallInternal(void* tag) {
612  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
613  context_->initial_metadata_flags());
614  // if corked bit is set in context, we just keep the initial metadata
615  // buffered up to coalesce with later message send. No op is performed.
616  if (!context_->initial_metadata_corked_) {
617  write_ops_.set_output_tag(tag);
618  call_.PerformOps(&write_ops_);
619  }
620  }
621 
622  ::grpc::ClientContext* context_;
624  bool started_;
626  meta_ops_;
629  read_ops_;
633  write_ops_;
636  finish_ops_;
637 };
638 
639 template <class W, class R>
643  public:
666  virtual void Finish(const W& msg, const ::grpc::Status& status,
667  void* tag) = 0;
668 
690  virtual void FinishWithError(const ::grpc::Status& status, void* tag) = 0;
691 };
692 
696 template <class W, class R>
697 class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
698  public:
700  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
701 
707  void SendInitialMetadata(void* tag) override {
708  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
709 
710  meta_ops_.set_output_tag(tag);
711  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
712  ctx_->initial_metadata_flags());
713  if (ctx_->compression_level_set()) {
714  meta_ops_.set_compression_level(ctx_->compression_level());
715  }
716  ctx_->sent_initial_metadata_ = true;
717  call_.PerformOps(&meta_ops_);
718  }
719 
720  void Read(R* msg, void* tag) override {
721  read_ops_.set_output_tag(tag);
722  read_ops_.RecvMessage(msg);
723  call_.PerformOps(&read_ops_);
724  }
725 
737  void Finish(const W& msg, const ::grpc::Status& status, void* tag) override {
738  finish_ops_.set_output_tag(tag);
739  if (!ctx_->sent_initial_metadata_) {
740  finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
741  ctx_->initial_metadata_flags());
742  if (ctx_->compression_level_set()) {
743  finish_ops_.set_compression_level(ctx_->compression_level());
744  }
745  ctx_->sent_initial_metadata_ = true;
746  }
747  // The response is dropped if the status is not OK.
748  if (status.ok()) {
749  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_,
750  finish_ops_.SendMessage(msg));
751  } else {
752  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
753  }
754  call_.PerformOps(&finish_ops_);
755  }
756 
766  void FinishWithError(const ::grpc::Status& status, void* tag) override {
767  GPR_CODEGEN_ASSERT(!status.ok());
768  finish_ops_.set_output_tag(tag);
769  if (!ctx_->sent_initial_metadata_) {
770  finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
771  ctx_->initial_metadata_flags());
772  if (ctx_->compression_level_set()) {
773  finish_ops_.set_compression_level(ctx_->compression_level());
774  }
775  ctx_->sent_initial_metadata_ = true;
776  }
777  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
778  call_.PerformOps(&finish_ops_);
779  }
780 
781  private:
782  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
783 
785  ::grpc::ServerContext* ctx_;
787  meta_ops_;
792  finish_ops_;
793 };
794 
795 template <class W>
799  public:
821  virtual void Finish(const ::grpc::Status& status, void* tag) = 0;
822 
837  virtual void WriteAndFinish(const W& msg, ::grpc::WriteOptions options,
838  const ::grpc::Status& status, void* tag) = 0;
839 };
840 
843 template <class W>
845  public:
847  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
848 
856  void SendInitialMetadata(void* tag) override {
857  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
858 
859  meta_ops_.set_output_tag(tag);
860  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
861  ctx_->initial_metadata_flags());
862  if (ctx_->compression_level_set()) {
863  meta_ops_.set_compression_level(ctx_->compression_level());
864  }
865  ctx_->sent_initial_metadata_ = true;
866  call_.PerformOps(&meta_ops_);
867  }
868 
869  void Write(const W& msg, void* tag) override {
870  write_ops_.set_output_tag(tag);
871  EnsureInitialMetadataSent(&write_ops_);
872  // TODO(ctiller): don't assert
873  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
874  call_.PerformOps(&write_ops_);
875  }
876 
877  void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override {
878  write_ops_.set_output_tag(tag);
879  if (options.is_last_message()) {
880  options.set_buffer_hint();
881  }
882 
883  EnsureInitialMetadataSent(&write_ops_);
884  // TODO(ctiller): don't assert
885  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
886  call_.PerformOps(&write_ops_);
887  }
888 
899  void WriteAndFinish(const W& msg, ::grpc::WriteOptions options,
900  const ::grpc::Status& status, void* tag) override {
901  write_ops_.set_output_tag(tag);
902  EnsureInitialMetadataSent(&write_ops_);
903  options.set_buffer_hint();
904  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
905  write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
906  call_.PerformOps(&write_ops_);
907  }
908 
920  void Finish(const ::grpc::Status& status, void* tag) override {
921  finish_ops_.set_output_tag(tag);
922  EnsureInitialMetadataSent(&finish_ops_);
923  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
924  call_.PerformOps(&finish_ops_);
925  }
926 
927  private:
928  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
929 
930  template <class T>
931  void EnsureInitialMetadataSent(T* ops) {
932  if (!ctx_->sent_initial_metadata_) {
933  ops->SendInitialMetadata(&ctx_->initial_metadata_,
934  ctx_->initial_metadata_flags());
935  if (ctx_->compression_level_set()) {
936  ops->set_compression_level(ctx_->compression_level());
937  }
938  ctx_->sent_initial_metadata_ = true;
939  }
940  }
941 
943  ::grpc::ServerContext* ctx_;
945  meta_ops_;
949  write_ops_;
952  finish_ops_;
953 };
954 
956 template <class W, class R>
961  public:
984  virtual void Finish(const ::grpc::Status& status, void* tag) = 0;
985 
1000  virtual void WriteAndFinish(const W& msg, ::grpc::WriteOptions options,
1001  const ::grpc::Status& status, void* tag) = 0;
1002 };
1003 
1008 template <class W, class R>
1010  : public ServerAsyncReaderWriterInterface<W, R> {
1011  public:
1013  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
1014 
1022  void SendInitialMetadata(void* tag) override {
1023  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
1024 
1025  meta_ops_.set_output_tag(tag);
1026  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
1027  ctx_->initial_metadata_flags());
1028  if (ctx_->compression_level_set()) {
1029  meta_ops_.set_compression_level(ctx_->compression_level());
1030  }
1031  ctx_->sent_initial_metadata_ = true;
1032  call_.PerformOps(&meta_ops_);
1033  }
1034 
1035  void Read(R* msg, void* tag) override {
1036  read_ops_.set_output_tag(tag);
1037  read_ops_.RecvMessage(msg);
1038  call_.PerformOps(&read_ops_);
1039  }
1040 
1041  void Write(const W& msg, void* tag) override {
1042  write_ops_.set_output_tag(tag);
1043  EnsureInitialMetadataSent(&write_ops_);
1044  // TODO(ctiller): don't assert
1045  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
1046  call_.PerformOps(&write_ops_);
1047  }
1048 
1049  void Write(const W& msg, ::grpc::WriteOptions options, void* tag) override {
1050  write_ops_.set_output_tag(tag);
1051  if (options.is_last_message()) {
1052  options.set_buffer_hint();
1053  }
1054  EnsureInitialMetadataSent(&write_ops_);
1055  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
1056  call_.PerformOps(&write_ops_);
1057  }
1058 
1067  //
1070  void WriteAndFinish(const W& msg, ::grpc::WriteOptions options,
1071  const ::grpc::Status& status, void* tag) override {
1072  write_ops_.set_output_tag(tag);
1073  EnsureInitialMetadataSent(&write_ops_);
1074  options.set_buffer_hint();
1075  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
1076  write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1077  call_.PerformOps(&write_ops_);
1078  }
1079 
1088  //
1091  void Finish(const ::grpc::Status& status, void* tag) override {
1092  finish_ops_.set_output_tag(tag);
1093  EnsureInitialMetadataSent(&finish_ops_);
1094 
1095  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1096  call_.PerformOps(&finish_ops_);
1097  }
1098 
1099  private:
1100  friend class ::grpc::Server;
1101 
1102  void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
1103 
1104  template <class T>
1105  void EnsureInitialMetadataSent(T* ops) {
1106  if (!ctx_->sent_initial_metadata_) {
1107  ops->SendInitialMetadata(&ctx_->initial_metadata_,
1108  ctx_->initial_metadata_flags());
1109  if (ctx_->compression_level_set()) {
1110  ops->set_compression_level(ctx_->compression_level());
1111  }
1112  ctx_->sent_initial_metadata_ = true;
1113  }
1114  }
1115 
1116  ::grpc::internal::Call call_;
1117  ::grpc::ServerContext* ctx_;
1119  meta_ops_;
1124  write_ops_;
1127  finish_ops_;
1128 };
1129 
1130 } // namespace grpc
1131 #endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: async_stream.h:197
void StartCall(void *tag) override
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
Definition: async_stream.h:211
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:234
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:225
void Finish(::grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:249
Definition: async_stream.h:166
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: async_stream.h:512
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:558
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method.
Definition: async_stream.h:539
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:548
void Write(const W &msg, ::grpc::WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:566
void Finish(::grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:589
void StartCall(void *tag) override
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
Definition: async_stream.h:526
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:578
Async client-side interface for bi-directional streaming, where the client-to-server message stream h...
Definition: async_stream.h:473
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: async_stream.h:345
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:372
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:381
void Write(const W &msg, ::grpc::WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:389
void StartCall(void *tag) override
Start the call that was set up by the constructor, but only if the constructor was invoked through th...
Definition: async_stream.h:359
void Finish(::grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:415
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:401
Common interface for client side asynchronous writing.
Definition: async_stream.h:303
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:193
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:102
virtual void * grpc_call_arena_alloc(grpc_call *call, size_t length)=0
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: async_stream.h:697
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:707
void Finish(const W &msg, const ::grpc::Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:737
ServerAsyncReader(::grpc::ServerContext *ctx)
Definition: async_stream.h:699
void FinishWithError(const ::grpc::Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:766
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:720
Definition: async_stream.h:642
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 ...
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.
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: async_stream.h:1010
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:1070
void Write(const W &msg, ::grpc::WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:1049
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:1022
void Finish(const ::grpc::Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream.h:1091
ServerAsyncReaderWriter(::grpc::ServerContext *ctx)
Definition: async_stream.h:1012
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:1041
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:1035
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:960
virtual void Finish(const ::grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
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,...
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: async_stream.h:844
ServerAsyncWriter(::grpc::ServerContext *ctx)
Definition: async_stream.h:846
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:869
void Write(const W &msg, ::grpc::WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:877
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:899
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:856
void Finish(const ::grpc::Status &status, void *tag) override
See the ServerAsyncWriterInterface.Finish method for semantics.
Definition: async_stream.h:920
Definition: async_stream.h:798
virtual void Finish(const ::grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
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,...
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:538
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:243
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context.h:228
Did it work? If it didn't, why?
Definition: status.h:31
Per-message write options.
Definition: call_op_set.h:79
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:181
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:156
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:117
An interface that yields a sequence of messages of type R.
Definition: async_stream.h:81
virtual ~AsyncReaderInterface()
Definition: async_stream.h:83
virtual void Read(R *msg, void *tag)=0
Read a message of type R into msg.
An interface that can be fed a sequence of messages of type W.
Definition: async_stream.h:103
virtual ~AsyncWriterInterface()
Definition: async_stream.h:105
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:156
virtual void Write(const W &msg, ::grpc::WriteOptions options, void *tag)=0
Request the writing of msg using WriteOptions options with identifying tag tag.
virtual void Write(const W &msg, void *tag)=0
Request the writing of msg with identifying tag tag.
Straightforward wrapping of the C call object.
Definition: call.h:35
grpc_call * call() const
Definition: call.h:69
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:65
Definition: call_op_set.h:769
Definition: call_op_set.h:619
Definition: call_op_set.h:526
Definition: call_op_set.h:721
Definition: call_op_set.h:424
Definition: call_op_set.h:212
Definition: call_op_set.h:282
Definition: call_op_set.h:654
Primary implementation of CallOpSetInterface.
Definition: call_op_set.h:867
Definition: async_stream.h:170
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:180
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:493
Common interface for all client side asynchronous streaming.
Definition: async_stream.h:32
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.
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...
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:34
virtual void ReadInitialMetadata(void *tag)=0
Request notification of the reading of the initial metadata.
Definition: async_stream.h:314
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:328
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
::google::protobuf::util::Status Status
Definition: config_protobuf.h:91
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
CoreCodegenInterface * g_core_codegen_interface
Null-initializes the global gRPC variables for the codegen library.
Definition: completion_queue.h:96