GRPC C++  1.70.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>(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  const W& request, bool start, void* tag)
271  : context_(context), call_(call), started_(start) {
272  // TODO(ctiller): don't assert
273  ABSL_CHECK(init_ops_.SendMessage(request).ok());
274  init_ops_.ClientSendClose();
275  if (start) {
276  StartCallInternal(tag);
277  } else {
278  ABSL_CHECK(tag == nullptr);
279  }
280  }
281 
282  void StartCallInternal(void* tag) {
283  init_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
284  context_->initial_metadata_flags());
285  init_ops_.set_output_tag(tag);
286  call_.PerformOps(&init_ops_);
287  }
288 
289  grpc::ClientContext* context_;
290  grpc::internal::Call call_;
291  bool started_;
295  init_ops_;
297  meta_ops_;
300  read_ops_;
303  finish_ops_;
304 };
305 
307 template <class W>
311  public:
316  virtual void WritesDone(void* tag) = 0;
317 };
318 
319 namespace internal {
320 template <class W>
321 class ClientAsyncWriterFactory {
322  public:
334  template <class R>
337  const grpc::internal::RpcMethod& method,
338  grpc::ClientContext* context, R* response,
339  bool start, void* tag) {
340  grpc::internal::Call call = channel->CreateCall(method, context, cq);
341  return new (
343  ClientAsyncWriter<W>(call, context, response, start, tag);
344  }
345 };
346 } // namespace internal
347 
351 template <class W>
352 class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
353  public:
354  // always allocated against a call arena, no memory free required
355  static void operator delete(void* /*ptr*/, std::size_t size) {
356  ABSL_CHECK_EQ(size, sizeof(ClientAsyncWriter));
357  }
358 
359  // This operator should never be called as the memory should be freed as part
360  // of the arena destruction. It only exists to provide a matching operator
361  // delete to the operator new so that some compilers will not complain (see
362  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
363  // there are no tests catching the compiler warning.
364  static void operator delete(void*, void*) { ABSL_CHECK(false); }
365 
366  void StartCall(void* tag) override {
367  ABSL_CHECK(!started_);
368  started_ = true;
369  StartCallInternal(tag);
370  }
371 
379  void ReadInitialMetadata(void* tag) override {
380  ABSL_CHECK(started_);
381  ABSL_CHECK(!context_->initial_metadata_received_);
382 
383  meta_ops_.set_output_tag(tag);
384  meta_ops_.RecvInitialMetadata(context_);
385  call_.PerformOps(&meta_ops_);
386  }
387 
388  void Write(const W& msg, void* tag) override {
389  ABSL_CHECK(started_);
390  write_ops_.set_output_tag(tag);
391  // TODO(ctiller): don't assert
392  ABSL_CHECK(write_ops_.SendMessage(msg).ok());
393  call_.PerformOps(&write_ops_);
394  }
395 
396  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
397  ABSL_CHECK(started_);
398  write_ops_.set_output_tag(tag);
399  if (options.is_last_message()) {
400  options.set_buffer_hint();
401  write_ops_.ClientSendClose();
402  }
403  // TODO(ctiller): don't assert
404  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
405  call_.PerformOps(&write_ops_);
406  }
407 
408  void WritesDone(void* tag) override {
409  ABSL_CHECK(started_);
410  write_ops_.set_output_tag(tag);
411  write_ops_.ClientSendClose();
412  call_.PerformOps(&write_ops_);
413  }
414 
422  void Finish(grpc::Status* status, void* tag) override {
423  ABSL_CHECK(started_);
424  finish_ops_.set_output_tag(tag);
425  if (!context_->initial_metadata_received_) {
426  finish_ops_.RecvInitialMetadata(context_);
427  }
428  finish_ops_.ClientRecvStatus(context_, status);
429  call_.PerformOps(&finish_ops_);
430  }
431 
432  private:
434  template <class R>
436  R* response, bool start, void* tag)
437  : context_(context), call_(call), started_(start) {
438  finish_ops_.RecvMessage(response);
439  finish_ops_.AllowNoMessage();
440  if (start) {
441  StartCallInternal(tag);
442  } else {
443  ABSL_CHECK(tag == nullptr);
444  }
445  }
446 
447  void StartCallInternal(void* tag) {
448  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
449  context_->initial_metadata_flags());
450  // if corked bit is set in context, we just keep the initial metadata
451  // buffered up to coalesce with later message send. No op is performed.
452  if (!context_->initial_metadata_corked_) {
453  write_ops_.set_output_tag(tag);
454  call_.PerformOps(&write_ops_);
455  }
456  }
457 
458  grpc::ClientContext* context_;
459  grpc::internal::Call call_;
460  bool started_;
462  meta_ops_;
466  write_ops_;
470  finish_ops_;
471 };
472 
476 template <class W, class R>
481  public:
486  virtual void WritesDone(void* tag) = 0;
487 };
488 
489 namespace internal {
490 template <class W, class R>
491 class ClientAsyncReaderWriterFactory {
492  public:
502  const grpc::internal::RpcMethod& method, grpc::ClientContext* context,
503  bool start, void* tag) {
504  grpc::internal::Call call = channel->CreateCall(method, context, cq);
505 
506  return new (grpc_call_arena_alloc(call.call(),
508  ClientAsyncReaderWriter<W, R>(call, context, start, tag);
509  }
510 };
511 } // namespace internal
512 
517 template <class W, class R>
518 class ClientAsyncReaderWriter final
519  : public ClientAsyncReaderWriterInterface<W, R> {
520  public:
521  // always allocated against a call arena, no memory free required
522  static void operator delete(void* /*ptr*/, std::size_t size) {
523  ABSL_CHECK_EQ(size, sizeof(ClientAsyncReaderWriter));
524  }
525 
526  // This operator should never be called as the memory should be freed as part
527  // of the arena destruction. It only exists to provide a matching operator
528  // delete to the operator new so that some compilers will not complain (see
529  // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this
530  // there are no tests catching the compiler warning.
531  static void operator delete(void*, void*) { ABSL_CHECK(false); }
532 
533  void StartCall(void* tag) override {
534  ABSL_CHECK(!started_);
535  started_ = true;
536  StartCallInternal(tag);
537  }
538 
546  void ReadInitialMetadata(void* tag) override {
547  ABSL_CHECK(started_);
548  ABSL_CHECK(!context_->initial_metadata_received_);
549 
550  meta_ops_.set_output_tag(tag);
551  meta_ops_.RecvInitialMetadata(context_);
552  call_.PerformOps(&meta_ops_);
553  }
554 
555  void Read(R* msg, void* tag) override {
556  ABSL_CHECK(started_);
557  read_ops_.set_output_tag(tag);
558  if (!context_->initial_metadata_received_) {
559  read_ops_.RecvInitialMetadata(context_);
560  }
561  read_ops_.RecvMessage(msg);
562  call_.PerformOps(&read_ops_);
563  }
564 
565  void Write(const W& msg, void* tag) override {
566  ABSL_CHECK(started_);
567  write_ops_.set_output_tag(tag);
568  // TODO(ctiller): don't assert
569  ABSL_CHECK(write_ops_.SendMessage(msg).ok());
570  call_.PerformOps(&write_ops_);
571  }
572 
573  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
574  ABSL_CHECK(started_);
575  write_ops_.set_output_tag(tag);
576  if (options.is_last_message()) {
577  options.set_buffer_hint();
578  write_ops_.ClientSendClose();
579  }
580  // TODO(ctiller): don't assert
581  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
582  call_.PerformOps(&write_ops_);
583  }
584 
585  void WritesDone(void* tag) override {
586  ABSL_CHECK(started_);
587  write_ops_.set_output_tag(tag);
588  write_ops_.ClientSendClose();
589  call_.PerformOps(&write_ops_);
590  }
591 
596  void Finish(grpc::Status* status, void* tag) override {
597  ABSL_CHECK(started_);
598  finish_ops_.set_output_tag(tag);
599  if (!context_->initial_metadata_received_) {
600  finish_ops_.RecvInitialMetadata(context_);
601  }
602  finish_ops_.ClientRecvStatus(context_, status);
603  call_.PerformOps(&finish_ops_);
604  }
605 
606  private:
609  grpc::ClientContext* context, bool start, void* tag)
610  : context_(context), call_(call), started_(start) {
611  if (start) {
612  StartCallInternal(tag);
613  } else {
614  ABSL_CHECK(tag == nullptr);
615  }
616  }
617 
618  void StartCallInternal(void* tag) {
619  write_ops_.SendInitialMetadata(&context_->send_initial_metadata_,
620  context_->initial_metadata_flags());
621  // if corked bit is set in context, we just keep the initial metadata
622  // buffered up to coalesce with later message send. No op is performed.
623  if (!context_->initial_metadata_corked_) {
624  write_ops_.set_output_tag(tag);
625  call_.PerformOps(&write_ops_);
626  }
627  }
628 
629  grpc::ClientContext* context_;
630  grpc::internal::Call call_;
631  bool started_;
633  meta_ops_;
636  read_ops_;
640  write_ops_;
643  finish_ops_;
644 };
645 
646 template <class W, class R>
650  public:
673  virtual void Finish(const W& msg, const grpc::Status& status, void* tag) = 0;
674 
696  virtual void FinishWithError(const grpc::Status& status, void* tag) = 0;
697 };
698 
702 template <class W, class R>
703 class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
704  public:
706  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
707 
713  void SendInitialMetadata(void* tag) override {
714  ABSL_CHECK(!ctx_->sent_initial_metadata_);
715 
716  meta_ops_.set_output_tag(tag);
717  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
718  ctx_->initial_metadata_flags());
719  if (ctx_->compression_level_set()) {
720  meta_ops_.set_compression_level(ctx_->compression_level());
721  }
722  ctx_->sent_initial_metadata_ = true;
723  call_.PerformOps(&meta_ops_);
724  }
725 
726  void Read(R* msg, void* tag) override {
727  read_ops_.set_output_tag(tag);
728  read_ops_.RecvMessage(msg);
729  call_.PerformOps(&read_ops_);
730  }
731 
743  void Finish(const W& msg, const grpc::Status& status, void* tag) override {
744  finish_ops_.set_output_tag(tag);
745  if (!ctx_->sent_initial_metadata_) {
746  finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
747  ctx_->initial_metadata_flags());
748  if (ctx_->compression_level_set()) {
749  finish_ops_.set_compression_level(ctx_->compression_level());
750  }
751  ctx_->sent_initial_metadata_ = true;
752  }
753  // The response is dropped if the status is not OK.
754  if (status.ok()) {
755  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_,
756  finish_ops_.SendMessage(msg));
757  } else {
758  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
759  }
760  call_.PerformOps(&finish_ops_);
761  }
762 
772  void FinishWithError(const grpc::Status& status, void* tag) override {
773  ABSL_CHECK(!status.ok());
774  finish_ops_.set_output_tag(tag);
775  if (!ctx_->sent_initial_metadata_) {
776  finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
777  ctx_->initial_metadata_flags());
778  if (ctx_->compression_level_set()) {
779  finish_ops_.set_compression_level(ctx_->compression_level());
780  }
781  ctx_->sent_initial_metadata_ = true;
782  }
783  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
784  call_.PerformOps(&finish_ops_);
785  }
786 
787  private:
788  void BindCall(grpc::internal::Call* call) override { call_ = *call; }
789 
790  grpc::internal::Call call_;
791  grpc::ServerContext* ctx_;
793  meta_ops_;
798  finish_ops_;
799 };
800 
801 template <class W>
805  public:
827  virtual void Finish(const grpc::Status& status, void* tag) = 0;
828 
843  virtual void WriteAndFinish(const W& msg, grpc::WriteOptions options,
844  const grpc::Status& status, void* tag) = 0;
845 };
846 
849 template <class W>
850 class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
851  public:
853  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
854 
862  void SendInitialMetadata(void* tag) override {
863  ABSL_CHECK(!ctx_->sent_initial_metadata_);
864 
865  meta_ops_.set_output_tag(tag);
866  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
867  ctx_->initial_metadata_flags());
868  if (ctx_->compression_level_set()) {
869  meta_ops_.set_compression_level(ctx_->compression_level());
870  }
871  ctx_->sent_initial_metadata_ = true;
872  call_.PerformOps(&meta_ops_);
873  }
874 
875  void Write(const W& msg, void* tag) override {
876  write_ops_.set_output_tag(tag);
877  EnsureInitialMetadataSent(&write_ops_);
878  // TODO(ctiller): don't assert
879  ABSL_CHECK(write_ops_.SendMessage(msg).ok());
880  call_.PerformOps(&write_ops_);
881  }
882 
883  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
884  write_ops_.set_output_tag(tag);
885  if (options.is_last_message()) {
886  options.set_buffer_hint();
887  }
888 
889  EnsureInitialMetadataSent(&write_ops_);
890  // TODO(ctiller): don't assert
891  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
892  call_.PerformOps(&write_ops_);
893  }
894 
905  void WriteAndFinish(const W& msg, grpc::WriteOptions options,
906  const grpc::Status& status, void* tag) override {
907  write_ops_.set_output_tag(tag);
908  EnsureInitialMetadataSent(&write_ops_);
909  options.set_buffer_hint();
910  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
911  write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
912  call_.PerformOps(&write_ops_);
913  }
914 
926  void Finish(const grpc::Status& status, void* tag) override {
927  finish_ops_.set_output_tag(tag);
928  EnsureInitialMetadataSent(&finish_ops_);
929  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
930  call_.PerformOps(&finish_ops_);
931  }
932 
933  private:
934  void BindCall(grpc::internal::Call* call) override { call_ = *call; }
935 
936  template <class T>
937  void EnsureInitialMetadataSent(T* ops) {
938  if (!ctx_->sent_initial_metadata_) {
939  ops->SendInitialMetadata(&ctx_->initial_metadata_,
940  ctx_->initial_metadata_flags());
941  if (ctx_->compression_level_set()) {
942  ops->set_compression_level(ctx_->compression_level());
943  }
944  ctx_->sent_initial_metadata_ = true;
945  }
946  }
947 
948  grpc::internal::Call call_;
949  grpc::ServerContext* ctx_;
951  meta_ops_;
955  write_ops_;
958  finish_ops_;
959 };
960 
962 template <class W, class R>
967  public:
990  virtual void Finish(const grpc::Status& status, void* tag) = 0;
991 
1006  virtual void WriteAndFinish(const W& msg, grpc::WriteOptions options,
1007  const grpc::Status& status, void* tag) = 0;
1008 };
1009 
1014 template <class W, class R>
1015 class ServerAsyncReaderWriter final
1016  : public ServerAsyncReaderWriterInterface<W, R> {
1017  public:
1019  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
1020 
1028  void SendInitialMetadata(void* tag) override {
1029  ABSL_CHECK(!ctx_->sent_initial_metadata_);
1030 
1031  meta_ops_.set_output_tag(tag);
1032  meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_,
1033  ctx_->initial_metadata_flags());
1034  if (ctx_->compression_level_set()) {
1035  meta_ops_.set_compression_level(ctx_->compression_level());
1036  }
1037  ctx_->sent_initial_metadata_ = true;
1038  call_.PerformOps(&meta_ops_);
1039  }
1040 
1041  void Read(R* msg, void* tag) override {
1042  read_ops_.set_output_tag(tag);
1043  read_ops_.RecvMessage(msg);
1044  call_.PerformOps(&read_ops_);
1045  }
1046 
1047  void Write(const W& msg, void* tag) override {
1048  write_ops_.set_output_tag(tag);
1049  EnsureInitialMetadataSent(&write_ops_);
1050  // TODO(ctiller): don't assert
1051  ABSL_CHECK(write_ops_.SendMessage(msg).ok());
1052  call_.PerformOps(&write_ops_);
1053  }
1054 
1055  void Write(const W& msg, grpc::WriteOptions options, void* tag) override {
1056  write_ops_.set_output_tag(tag);
1057  if (options.is_last_message()) {
1058  options.set_buffer_hint();
1059  }
1060  EnsureInitialMetadataSent(&write_ops_);
1061  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
1062  call_.PerformOps(&write_ops_);
1063  }
1064 
1073  //
1076  void WriteAndFinish(const W& msg, grpc::WriteOptions options,
1077  const grpc::Status& status, void* tag) override {
1078  write_ops_.set_output_tag(tag);
1079  EnsureInitialMetadataSent(&write_ops_);
1080  options.set_buffer_hint();
1081  ABSL_CHECK(write_ops_.SendMessage(msg, options).ok());
1082  write_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1083  call_.PerformOps(&write_ops_);
1084  }
1085 
1094  //
1097  void Finish(const grpc::Status& status, void* tag) override {
1098  finish_ops_.set_output_tag(tag);
1099  EnsureInitialMetadataSent(&finish_ops_);
1100 
1101  finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, status);
1102  call_.PerformOps(&finish_ops_);
1103  }
1104 
1105  private:
1106  friend class grpc::Server;
1107 
1108  void BindCall(grpc::internal::Call* call) override { call_ = *call; }
1109 
1110  template <class T>
1111  void EnsureInitialMetadataSent(T* ops) {
1112  if (!ctx_->sent_initial_metadata_) {
1113  ops->SendInitialMetadata(&ctx_->initial_metadata_,
1114  ctx_->initial_metadata_flags());
1115  if (ctx_->compression_level_set()) {
1116  ops->set_compression_level(ctx_->compression_level());
1117  }
1118  ctx_->sent_initial_metadata_ = true;
1119  }
1120  }
1121 
1122  grpc::internal::Call call_;
1123  grpc::ServerContext* ctx_;
1125  meta_ops_;
1130  write_ops_;
1133  finish_ops_;
1134 };
1135 
1136 } // namespace grpc
1137 
1138 #endif // GRPCPP_SUPPORT_ASYNC_STREAM_H
grpc::internal::CallOpRecvInitialMetadata
Definition: call_op_set.h:723
grpc::ClientAsyncReaderWriter::Finish
void Finish(grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:596
grpc::ServerAsyncReaderWriter::Read
void Read(R *msg, void *tag) override
Definition: async_stream.h:1041
grpc::ClientAsyncWriter::StartCall
void StartCall(void *tag) override
Definition: async_stream.h:366
grpc::internal::ServerAsyncStreamingInterface
Definition: service_type.h:38
grpc::internal::CallOpClientSendClose
Definition: call_op_set.h:621
grpc_call_arena_alloc
GRPCAPI void * grpc_call_arena_alloc(grpc_call *call, size_t size)
Allocate memory in the grpc_call arena: this memory is automatically discarded at call completion.
grpc::internal::CallOpGenericRecvMessage
Definition: call_op_set.h:528
grpc::internal::AsyncWriterInterface
An interface that can be fed a sequence of messages of type W.
Definition: async_stream.h:110
grpc::ServerContext
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:578
grpc::internal::CallOpServerSendStatus
Definition: call_op_set.h:656
grpc::Server
Represents a gRPC server.
Definition: server.h:57
grpc::ClientAsyncReaderWriter::ReadInitialMetadata
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method.
Definition: async_stream.h:546
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:555
grpc::internal::ClientAsyncStreamingInterface::~ClientAsyncStreamingInterface
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:37
grpc::internal::CallOpSendMessage
Definition: call_op_set.h:288
grpc::ServerAsyncReaderWriter::Write
void Write(const W &msg, grpc::WriteOptions options, void *tag) override
Definition: async_stream.h:1055
grpc::ClientAsyncWriter::Write
void Write(const W &msg, void *tag) override
Definition: async_stream.h:388
grpc::ServerAsyncWriter
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: server_context.h:58
grpc::internal::ClientAsyncReaderWriterFactory
Definition: channel_interface.h:42
grpc::WriteOptions::set_last_message
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call_op_set.h:157
grpc::ClientAsyncReader::StartCall
void StartCall(void *tag) override
Definition: async_stream.h: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:743
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:875
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:335
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:36
grpc::ClientAsyncReaderWriter::WritesDone
void WritesDone(void *tag) override
Definition: async_stream.h:585
grpc::ServerAsyncReader::ServerAsyncReader
ServerAsyncReader(grpc::ServerContext *ctx)
Definition: async_stream.h:705
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:1076
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:218
grpc::ServerAsyncReaderInterface::FinishWithError
virtual void FinishWithError(const grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain non-OK status code.
grpc::internal::ClientAsyncStreamingInterface::ReadInitialMetadata
virtual void ReadInitialMetadata(void *tag)=0
Request notification of the reading of the initial metadata.
grpc::internal::ClientAsyncReaderWriterFactory::Create
static ClientAsyncReaderWriter< W, R > * Create(grpc::ChannelInterface *channel, grpc::CompletionQueue *cq, const grpc::internal::RpcMethod &method, grpc::ClientContext *context, bool start, void *tag)
Create a stream object.
Definition: async_stream.h:500
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:396
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:1047
grpc::ServerAsyncReader::Read
void Read(R *msg, void *tag) override
Definition: async_stream.h:726
grpc::ClientAsyncReaderWriterInterface
Async client-side interface for bi-directional streaming, where the client-to-server message stream h...
Definition: async_stream.h:477
grpc::ClientAsyncWriter::Finish
void Finish(grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:422
grpc::ServerAsyncReaderWriter::ServerAsyncReaderWriter
ServerAsyncReaderWriter(grpc::ServerContext *ctx)
Definition: async_stream.h:1018
grpc::ServerAsyncWriterInterface
Definition: async_stream.h:802
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:38
grpc::ServerAsyncWriterInterface::WriteAndFinish
virtual void WriteAndFinish(const W &msg, grpc::WriteOptions options, const grpc::Status &status, void *tag)=0
Request the writing of msg and coalesce it with trailing metadata which contains status,...
grpc::internal::ClientAsyncStreamingInterface
Common interface for all client side asynchronous streaming.
Definition: async_stream.h: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:408
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:963
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:883
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:1028
grpc::ClientAsyncWriterInterface::WritesDone
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
grpc::internal::ClientAsyncStreamingInterface::Finish
virtual void Finish(grpc::Status *status, void *tag)=0
Indicate that the stream is to be finished and request notification for when the call has been ended.
channel_interface.h
grpc::ChannelInterface
Codegen interface for grpc::Channel.
Definition: channel_interface.h:71
grpc::ClientAsyncWriter::ReadInitialMetadata
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:379
grpc::ServerAsyncReaderWriter::Finish
void Finish(const grpc::Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream.h:1097
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:308
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:772
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:905
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:939
grpc::WriteOptions
Per-message write options.
Definition: call_op_set.h:80
grpc::ServerAsyncWriterInterface::Finish
virtual void Finish(const grpc::Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
grpc::internal::AsyncReaderInterface
An interface that yields a sequence of messages of type R.
Definition: async_stream.h: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:713
grpc::ClientAsyncReaderWriter::Write
void Write(const W &msg, void *tag) override
Definition: async_stream.h:565
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:573
grpc::internal::Call::call
grpc_call * call() const
Definition: call.h:70
server_context.h
call.h
grpc::ServerContext::compression_level_set
bool compression_level_set() const
Return a bool indicating whether the compression level for this call has been set (either implicitly ...
Definition: server_context.h:251
grpc::internal::CallOpClientRecvStatus
Definition: call_op_set.h:771
grpc::WriteOptions::set_buffer_hint
WriteOptions & set_buffer_hint()
Sets flag indicating that the write may be buffered and need not go out on the wire immediately.
Definition: call_op_set.h:118
service_type.h
grpc::CompletionQueue
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:104
grpc::internal::ClientAsyncWriterFactory
Definition: channel_interface.h:40
grpc::ClientAsyncReader::Finish
void Finish(grpc::Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:256
grpc::internal::AsyncReaderInterface::~AsyncReaderInterface
virtual ~AsyncReaderInterface()
Definition: async_stream.h:90
grpc::ClientAsyncReaderWriter::StartCall
void StartCall(void *tag) override
Definition: async_stream.h:533
grpc::ServerAsyncReaderInterface
Definition: async_stream.h:647
grpc::ServerAsyncWriter::Finish
void Finish(const grpc::Status &status, void *tag) override
See the ServerAsyncWriterInterface.Finish method for semantics.
Definition: async_stream.h:926
grpc::ServerAsyncWriter::SendInitialMetadata
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:862
grpc::WriteOptions::is_last_message
bool is_last_message() const
Get value for the flag indicating that this is the last message, and should be coalesced with trailin...
Definition: call_op_set.h:173
grpc::ServerAsyncReader
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: server_context.h:56
grpc::internal::CallOpRecvMessage
Definition: call_op_set.h:426
grpc::internal::RpcMethod
Descriptor of an RPC method.
Definition: rpc_method.h:29
grpc::ServerAsyncReaderWriter
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: server_context.h:62
grpc::ServerAsyncWriter::ServerAsyncWriter
ServerAsyncWriter(grpc::ServerContext *ctx)
Definition: async_stream.h:852
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.