GRPC C++  1.22.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_IMPL_CODEGEN_ASYNC_STREAM_H
20 #define GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
21 
28 
29 namespace grpc {
30 
31 namespace internal {
34  public:
36 
40  virtual void StartCall(void* tag) = 0;
41 
48  virtual void ReadInitialMetadata(void* tag) = 0;
49 
77  virtual void Finish(Status* status, void* tag) = 0;
78 };
79 
81 template <class R>
83  public:
84  virtual ~AsyncReaderInterface() {}
85 
99  virtual void Read(R* msg, void* tag) = 0;
100 };
101 
103 template <class W>
105  public:
107 
120  virtual void Write(const W& msg, void* tag) = 0;
121 
137  virtual void Write(const W& msg, WriteOptions options, void* tag) = 0;
138 
157  void WriteLast(const W& msg, WriteOptions options, void* tag) {
158  Write(msg, options.set_last_message(), tag);
159  }
160 };
161 
162 } // namespace internal
163 
164 template <class R>
167  public internal::AsyncReaderInterface<R> {};
168 
169 namespace internal {
170 template <class R>
172  public:
180  template <class W>
182  CompletionQueue* cq,
183  const ::grpc::internal::RpcMethod& method,
184  ClientContext* context, const W& request,
185  bool start, void* tag) {
186  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
188  call.call(), sizeof(ClientAsyncReader<R>)))
189  ClientAsyncReader<R>(call, context, request, start, tag);
190  }
191 };
192 } // namespace internal
193 
197 template <class R>
199  public:
200  // always allocated against a call arena, no memory free required
201  static void operator delete(void* ptr, std::size_t size) {
202  assert(size == sizeof(ClientAsyncReader));
203  }
204 
205  // This operator should never be called as the memory should be freed as part
206  // of the arena destruction. It only exists to provide a matching operator
207  // delete to the operator new so that some compilers will not complain (see
208  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
209  // there are no tests catching the compiler warning.
210  static void operator delete(void*, void*) { assert(0); }
211 
212  void StartCall(void* tag) override {
213  assert(!started_);
214  started_ = true;
215  StartCallInternal(tag);
216  }
217 
226  void ReadInitialMetadata(void* tag) override {
227  assert(started_);
228  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
229 
230  meta_ops_.set_output_tag(tag);
231  meta_ops_.RecvInitialMetadata(context_);
232  call_.PerformOps(&meta_ops_);
233  }
234 
235  void Read(R* msg, void* tag) override {
236  assert(started_);
237  read_ops_.set_output_tag(tag);
238  if (!context_->initial_metadata_received_) {
239  read_ops_.RecvInitialMetadata(context_);
240  }
241  read_ops_.RecvMessage(msg);
242  call_.PerformOps(&read_ops_);
243  }
244 
250  void Finish(Status* status, void* tag) override {
251  assert(started_);
252  finish_ops_.set_output_tag(tag);
253  if (!context_->initial_metadata_received_) {
254  finish_ops_.RecvInitialMetadata(context_);
255  }
256  finish_ops_.ClientRecvStatus(context_, status);
257  call_.PerformOps(&finish_ops_);
258  }
259 
260  private:
262  template <class W>
264  const W& request, bool start, void* tag)
265  : context_(context), call_(call), started_(start) {
266  // TODO(ctiller): don't assert
267  GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok());
268  init_ops_.ClientSendClose();
269  if (start) {
270  StartCallInternal(tag);
271  } else {
272  assert(tag == nullptr);
273  }
274  }
275 
276  void StartCallInternal(void* tag) {
277  init_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
278  context_->initial_metadata_flags());
279  init_ops_.set_output_tag(tag);
280  call_.PerformOps(&init_ops_);
281  }
282 
283  ClientContext* context_;
285  bool started_;
289  init_ops_;
291  meta_ops_;
294  read_ops_;
295  ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
297  finish_ops_;
298 };
299 
301 template <class W>
305  public:
310  virtual void WritesDone(void* tag) = 0;
311 };
312 
313 namespace internal {
314 template <class W>
316  public:
328  template <class R>
330  CompletionQueue* cq,
331  const ::grpc::internal::RpcMethod& method,
332  ClientContext* context, R* response,
333  bool start, void* tag) {
334  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
336  call.call(), sizeof(ClientAsyncWriter<W>)))
337  ClientAsyncWriter<W>(call, context, response, start, tag);
338  }
339 };
340 } // namespace internal
341 
345 template <class W>
347  public:
348  // always allocated against a call arena, no memory free required
349  static void operator delete(void* ptr, std::size_t size) {
350  assert(size == sizeof(ClientAsyncWriter));
351  }
352 
353  // This operator should never be called as the memory should be freed as part
354  // of the arena destruction. It only exists to provide a matching operator
355  // delete to the operator new so that some compilers will not complain (see
356  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
357  // there are no tests catching the compiler warning.
358  static void operator delete(void*, void*) { assert(0); }
359 
360  void StartCall(void* tag) override {
361  assert(!started_);
362  started_ = true;
363  StartCallInternal(tag);
364  }
365 
373  void ReadInitialMetadata(void* tag) override {
374  assert(started_);
375  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
376 
377  meta_ops_.set_output_tag(tag);
378  meta_ops_.RecvInitialMetadata(context_);
379  call_.PerformOps(&meta_ops_);
380  }
381 
382  void Write(const W& msg, void* tag) override {
383  assert(started_);
384  write_ops_.set_output_tag(tag);
385  // TODO(ctiller): don't assert
386  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
387  call_.PerformOps(&write_ops_);
388  }
389 
390  void Write(const W& msg, WriteOptions options, void* tag) override {
391  assert(started_);
392  write_ops_.set_output_tag(tag);
393  if (options.is_last_message()) {
394  options.set_buffer_hint();
395  write_ops_.ClientSendClose();
396  }
397  // TODO(ctiller): don't assert
398  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
399  call_.PerformOps(&write_ops_);
400  }
401 
402  void WritesDone(void* tag) override {
403  assert(started_);
404  write_ops_.set_output_tag(tag);
405  write_ops_.ClientSendClose();
406  call_.PerformOps(&write_ops_);
407  }
408 
416  void Finish(Status* status, void* tag) override {
417  assert(started_);
418  finish_ops_.set_output_tag(tag);
419  if (!context_->initial_metadata_received_) {
420  finish_ops_.RecvInitialMetadata(context_);
421  }
422  finish_ops_.ClientRecvStatus(context_, status);
423  call_.PerformOps(&finish_ops_);
424  }
425 
426  private:
428  template <class R>
430  R* response, bool start, void* tag)
431  : context_(context), call_(call), started_(start) {
432  finish_ops_.RecvMessage(response);
433  finish_ops_.AllowNoMessage();
434  if (start) {
435  StartCallInternal(tag);
436  } else {
437  assert(tag == nullptr);
438  }
439  }
440 
441  void StartCallInternal(void* tag) {
442  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
443  context_->initial_metadata_flags());
444  // if corked bit is set in context, we just keep the initial metadata
445  // buffered up to coalesce with later message send. No op is performed.
446  if (!context_->initial_metadata_corked_) {
447  write_ops_.set_output_tag(tag);
448  call_.PerformOps(&write_ops_);
449  }
450  }
451 
452  ClientContext* context_;
454  bool started_;
456  meta_ops_;
460  write_ops_;
464  finish_ops_;
465 };
466 
470 template <class W, class R>
475  public:
480  virtual void WritesDone(void* tag) = 0;
481 };
482 
483 namespace internal {
484 template <class W, class R>
486  public:
495  ChannelInterface* channel, CompletionQueue* cq,
496  const ::grpc::internal::RpcMethod& method, ClientContext* context,
497  bool start, void* tag) {
498  ::grpc::internal::Call call = channel->CreateCall(method, context, cq);
499 
501  call.call(), sizeof(ClientAsyncReaderWriter<W, R>)))
502  ClientAsyncReaderWriter<W, R>(call, context, start, tag);
503  }
504 };
505 } // namespace internal
506 
511 template <class W, class R>
513  : public ClientAsyncReaderWriterInterface<W, R> {
514  public:
515  // always allocated against a call arena, no memory free required
516  static void operator delete(void* ptr, std::size_t size) {
517  assert(size == sizeof(ClientAsyncReaderWriter));
518  }
519 
520  // This operator should never be called as the memory should be freed as part
521  // of the arena destruction. It only exists to provide a matching operator
522  // delete to the operator new so that some compilers will not complain (see
523  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
524  // there are no tests catching the compiler warning.
525  static void operator delete(void*, void*) { assert(0); }
526 
527  void StartCall(void* tag) override {
528  assert(!started_);
529  started_ = true;
530  StartCallInternal(tag);
531  }
532 
540  void ReadInitialMetadata(void* tag) override {
541  assert(started_);
542  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
543 
544  meta_ops_.set_output_tag(tag);
545  meta_ops_.RecvInitialMetadata(context_);
546  call_.PerformOps(&meta_ops_);
547  }
548 
549  void Read(R* msg, void* tag) override {
550  assert(started_);
551  read_ops_.set_output_tag(tag);
552  if (!context_->initial_metadata_received_) {
553  read_ops_.RecvInitialMetadata(context_);
554  }
555  read_ops_.RecvMessage(msg);
556  call_.PerformOps(&read_ops_);
557  }
558 
559  void Write(const W& msg, void* tag) override {
560  assert(started_);
561  write_ops_.set_output_tag(tag);
562  // TODO(ctiller): don't assert
563  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
564  call_.PerformOps(&write_ops_);
565  }
566 
567  void Write(const W& msg, WriteOptions options, void* tag) override {
568  assert(started_);
569  write_ops_.set_output_tag(tag);
570  if (options.is_last_message()) {
571  options.set_buffer_hint();
572  write_ops_.ClientSendClose();
573  }
574  // TODO(ctiller): don't assert
575  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
576  call_.PerformOps(&write_ops_);
577  }
578 
579  void WritesDone(void* tag) override {
580  assert(started_);
581  write_ops_.set_output_tag(tag);
582  write_ops_.ClientSendClose();
583  call_.PerformOps(&write_ops_);
584  }
585 
590  void Finish(Status* status, void* tag) override {
591  assert(started_);
592  finish_ops_.set_output_tag(tag);
593  if (!context_->initial_metadata_received_) {
594  finish_ops_.RecvInitialMetadata(context_);
595  }
596  finish_ops_.ClientRecvStatus(context_, status);
597  call_.PerformOps(&finish_ops_);
598  }
599 
600  private:
603  bool start, void* tag)
604  : context_(context), call_(call), started_(start) {
605  if (start) {
606  StartCallInternal(tag);
607  } else {
608  assert(tag == nullptr);
609  }
610  }
611 
612  void StartCallInternal(void* tag) {
613  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
614  context_->initial_metadata_flags());
615  // if corked bit is set in context, we just keep the initial metadata
616  // buffered up to coalesce with later message send. No op is performed.
617  if (!context_->initial_metadata_corked_) {
618  write_ops_.set_output_tag(tag);
619  call_.PerformOps(&write_ops_);
620  }
621  }
622 
623  ClientContext* context_;
625  bool started_;
627  meta_ops_;
630  read_ops_;
634  write_ops_;
635  ::grpc::internal::CallOpSet<::grpc::internal::CallOpRecvInitialMetadata,
637  finish_ops_;
638 };
639 
640 template <class W, class R>
644  public:
667  virtual void Finish(const W& msg, const Status& status, void* tag) = 0;
668 
690  virtual void FinishWithError(const 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 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 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  ServerContext* ctx_;
787  meta_ops_;
792  finish_ops_;
793 };
794 
795 template <class W>
799  public:
821  virtual void Finish(const Status& status, void* tag) = 0;
822 
837  virtual void WriteAndFinish(const W& msg, WriteOptions options,
838  const 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, 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, WriteOptions options, const Status& status,
900  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 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  ServerContext* ctx_;
945  meta_ops_;
949  write_ops_;
950  ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
952  finish_ops_;
953 };
954 
956 template <class W, class R>
961  public:
984  virtual void Finish(const Status& status, void* tag) = 0;
985 
1000  virtual void WriteAndFinish(const W& msg, WriteOptions options,
1001  const 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, 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, WriteOptions options, const Status& status,
1071  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 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:
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  ServerContext* ctx_;
1119  meta_ops_;
1124  write_ops_;
1125  ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
1127  finish_ops_;
1128 };
1129 
1130 } // namespace grpc
1131 
1132 #endif // GRPCPP_IMPL_CODEGEN_ASYNC_STREAM_H
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: async_stream.h:512
virtual ~AsyncReaderInterface()
Definition: async_stream.h:84
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:720
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:125
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:145
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:235
static ClientAsyncWriter< W > * Create(ChannelInterface *channel, CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ClientContext *context, R *response, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:329
static ClientAsyncReaderWriter< W, R > * Create(ChannelInterface *channel, CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ClientContext *context, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:494
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:164
::grpc_impl::Server Server
Definition: server.h:26
Primary implementation of CallOpSetInterface.
Definition: call_op_set.h:821
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: async_stream.h:1009
void FinishWithError(const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:766
void Write(const W &msg, WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:1049
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:590
Definition: async_stream.h:641
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...
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:250
grpc_call * call() const
Definition: call.h:72
A ServerContext allows the person implementing a service handler to:
Definition: server_context_impl.h:114
Definition: async_stream.h:315
Definition: async_stream.h:171
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:869
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: async_stream.h:844
static ClientAsyncReader< R > * Create(ChannelInterface *channel, CompletionQueue *cq, const ::grpc::internal::RpcMethod &method, ClientContext *context, const W &request, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:181
void Finish(const W &msg, const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:737
An interface that yields a sequence of messages of type R.
Definition: async_stream.h:82
void Finish(const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream.h:1091
Definition: call_op_set.h:629
Definition: call_op_set.h:218
void Write(const W &msg, WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:567
ServerAsyncReaderWriter(ServerContext *ctx)
Definition: async_stream.h:1012
Definition: call_op_set.h:696
Definition: async_stream.h:165
Definition: call_op_set.h:288
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:1022
virtual void Finish(Status *status, void *tag)=0
Indicate that the stream is to be finished and request notification for when the call has been ended...
Async client-side interface for bi-directional streaming, where the client-to-server message stream h...
Definition: async_stream.h:471
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
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:360
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:212
Codegen interface for grpc::Channel.
Definition: channel_interface.h:69
ServerAsyncWriter(ServerContext *ctx)
Definition: async_stream.h:846
CoreCodegenInterface * g_core_codegen_interface
Definition: call_op_set.h:51
virtual void ReadInitialMetadata(void *tag)=0
Request notification of the reading of the initial metadata.
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:856
void WriteLast(const W &msg, WriteOptions options, void *tag)
Request the writing of msg and coalesce it with the writing of trailing metadata, using WriteOptions ...
Definition: async_stream.h:157
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: async_stream.h:346
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:957
Definition: byte_buffer.h:41
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:579
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:707
Per-message write options.
Definition: call_op_set.h:85
void Write(const W &msg, WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:877
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:382
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:1070
Definition: call_op_set.h:594
virtual void * grpc_call_arena_alloc(grpc_call *call, size_t length)=0
bool ok() const
Is the status OK?
Definition: status.h:118
An interface that can be fed a sequence of messages of type W.
Definition: async_stream.h:104
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:226
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue_impl.h:102
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:35
void Write(const W &msg, WriteOptions options, void *tag) override
Request the writing of msg using WriteOptions options with identifying tag tag.
Definition: async_stream.h:390
A ClientContext allows the person implementing a service client to:
Definition: client_context_impl.h:178
Did it work? If it didn&#39;t, why?
Definition: status.h:31
void Finish(const Status &status, void *tag) override
See the ServerAsyncWriterInterface.Finish method for semantics.
Definition: async_stream.h:920
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method...
Definition: async_stream.h:540
Definition: async_stream.h:796
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:416
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:402
Definition: call_op_set.h:516
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:189
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:559
Definition: call_op_set.h:744
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: async_stream.h:198
virtual ~AsyncWriterInterface()
Definition: async_stream.h:106
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:1035
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:549
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:899
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:527
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: async_stream.h:697
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:373
Common interface for all client side asynchronous streaming.
Definition: async_stream.h:33
Straightforward wrapping of the C call object.
Definition: call.h:38
ServerAsyncReader(ServerContext *ctx)
Definition: async_stream.h:699
Common interface for client side asynchronous writing.
Definition: async_stream.h:302