GRPC C++  1.4.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
async_stream.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H
35 #define GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H
36 
43 
44 namespace grpc {
45 
46 class CompletionQueue;
47 
50  public:
52 
59  virtual void ReadInitialMetadata(void* tag) = 0;
60 
88  virtual void Finish(Status* status, void* tag) = 0;
89 };
90 
92 template <class R>
94  public:
95  virtual ~AsyncReaderInterface() {}
96 
110  virtual void Read(R* msg, void* tag) = 0;
111 };
112 
114 template <class W>
116  public:
118 
128  virtual void Write(const W& msg, void* tag) = 0;
129 
142  virtual void Write(const W& msg, WriteOptions options, void* tag) = 0;
143 
159  void WriteLast(const W& msg, WriteOptions options, void* tag) {
160  Write(msg, options.set_last_message(), tag);
161  }
162 };
163 
164 template <class R>
166  public AsyncReaderInterface<R> {};
167 
171 template <class R>
173  public:
179  template <class W>
181  CompletionQueue* cq, const RpcMethod& method,
182  ClientContext* context, const W& request,
183  void* tag) {
184  Call call = channel->CreateCall(method, context, cq);
186  call.call(), sizeof(ClientAsyncReader)))
187  ClientAsyncReader(call, context, request, tag);
188  }
189 
190  // always allocated against a call arena, no memory free required
191  static void operator delete(void* ptr, std::size_t size) {
192  assert(size == sizeof(ClientAsyncReader));
193  }
194 
203  void ReadInitialMetadata(void* tag) override {
204  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
205 
206  meta_ops_.set_output_tag(tag);
207  meta_ops_.RecvInitialMetadata(context_);
208  call_.PerformOps(&meta_ops_);
209  }
210 
211  void Read(R* msg, void* tag) override {
212  read_ops_.set_output_tag(tag);
213  if (!context_->initial_metadata_received_) {
214  read_ops_.RecvInitialMetadata(context_);
215  }
216  read_ops_.RecvMessage(msg);
217  call_.PerformOps(&read_ops_);
218  }
219 
225  void Finish(Status* status, void* tag) override {
226  finish_ops_.set_output_tag(tag);
227  if (!context_->initial_metadata_received_) {
228  finish_ops_.RecvInitialMetadata(context_);
229  }
230  finish_ops_.ClientRecvStatus(context_, status);
231  call_.PerformOps(&finish_ops_);
232  }
233 
234  private:
235  template <class W>
236  ClientAsyncReader(Call call, ClientContext* context, const W& request,
237  void* tag)
238  : context_(context), call_(call) {
239  init_ops_.set_output_tag(tag);
240  init_ops_.SendInitialMetadata(context->send_initial_metadata_,
241  context->initial_metadata_flags());
242  // TODO(ctiller): don't assert
243  GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok());
244  init_ops_.ClientSendClose();
245  call_.PerformOps(&init_ops_);
246  }
247 
248  ClientContext* context_;
249  Call call_;
250  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose>
251  init_ops_;
252  CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
253  CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> read_ops_;
254  CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> finish_ops_;
255 };
256 
258 template <class W>
260  public AsyncWriterInterface<W> {
261  public:
266  virtual void WritesDone(void* tag) = 0;
267 };
268 
272 template <class W>
274  public:
283  template <class R>
285  CompletionQueue* cq, const RpcMethod& method,
286  ClientContext* context, R* response,
287  void* tag) {
288  Call call = channel->CreateCall(method, context, cq);
290  call.call(), sizeof(ClientAsyncWriter)))
291  ClientAsyncWriter(call, context, response, tag);
292  }
293 
294  // always allocated against a call arena, no memory free required
295  static void operator delete(void* ptr, std::size_t size) {
296  assert(size == sizeof(ClientAsyncWriter));
297  }
298 
306  void ReadInitialMetadata(void* tag) override {
307  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
308 
309  meta_ops_.set_output_tag(tag);
310  meta_ops_.RecvInitialMetadata(context_);
311  call_.PerformOps(&meta_ops_);
312  }
313 
314  void Write(const W& msg, void* tag) override {
315  write_ops_.set_output_tag(tag);
316  // TODO(ctiller): don't assert
317  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
318  call_.PerformOps(&write_ops_);
319  }
320 
321  void Write(const W& msg, WriteOptions options, void* tag) override {
322  write_ops_.set_output_tag(tag);
323  if (options.is_last_message()) {
324  options.set_buffer_hint();
325  write_ops_.ClientSendClose();
326  }
327  // TODO(ctiller): don't assert
328  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
329  call_.PerformOps(&write_ops_);
330  }
331 
332  void WritesDone(void* tag) override {
333  write_ops_.set_output_tag(tag);
334  write_ops_.ClientSendClose();
335  call_.PerformOps(&write_ops_);
336  }
337 
345  void Finish(Status* status, void* tag) override {
346  finish_ops_.set_output_tag(tag);
347  if (!context_->initial_metadata_received_) {
348  finish_ops_.RecvInitialMetadata(context_);
349  }
350  finish_ops_.ClientRecvStatus(context_, status);
351  call_.PerformOps(&finish_ops_);
352  }
353 
354  private:
355  template <class R>
356  ClientAsyncWriter(Call call, ClientContext* context, R* response, void* tag)
357  : context_(context), call_(call) {
358  finish_ops_.RecvMessage(response);
359  finish_ops_.AllowNoMessage();
360  // if corked bit is set in context, we buffer up the initial metadata to
361  // coalesce with later message to be sent. No op is performed.
362  if (context_->initial_metadata_corked_) {
363  write_ops_.SendInitialMetadata(context->send_initial_metadata_,
364  context->initial_metadata_flags());
365  } else {
366  write_ops_.set_output_tag(tag);
367  write_ops_.SendInitialMetadata(context->send_initial_metadata_,
368  context->initial_metadata_flags());
369  call_.PerformOps(&write_ops_);
370  }
371  }
372 
373  ClientContext* context_;
374  Call call_;
375  CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
376  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose>
377  write_ops_;
378  CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage,
379  CallOpClientRecvStatus>
380  finish_ops_;
381 };
382 
386 template <class W, class R>
388  public AsyncWriterInterface<W>,
389  public AsyncReaderInterface<R> {
390  public:
395  virtual void WritesDone(void* tag) = 0;
396 };
397 
402 template <class W, class R>
404  : public ClientAsyncReaderWriterInterface<W, R> {
405  public:
412  CompletionQueue* cq,
413  const RpcMethod& method,
414  ClientContext* context, void* tag) {
415  Call call = channel->CreateCall(method, context, cq);
416 
418  call.call(), sizeof(ClientAsyncReaderWriter)))
419  ClientAsyncReaderWriter(call, context, tag);
420  }
421 
422  // always allocated against a call arena, no memory free required
423  static void operator delete(void* ptr, std::size_t size) {
424  assert(size == sizeof(ClientAsyncReaderWriter));
425  }
426 
434  void ReadInitialMetadata(void* tag) override {
435  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
436 
437  meta_ops_.set_output_tag(tag);
438  meta_ops_.RecvInitialMetadata(context_);
439  call_.PerformOps(&meta_ops_);
440  }
441 
442  void Read(R* msg, void* tag) override {
443  read_ops_.set_output_tag(tag);
444  if (!context_->initial_metadata_received_) {
445  read_ops_.RecvInitialMetadata(context_);
446  }
447  read_ops_.RecvMessage(msg);
448  call_.PerformOps(&read_ops_);
449  }
450 
451  void Write(const W& msg, void* tag) override {
452  write_ops_.set_output_tag(tag);
453  // TODO(ctiller): don't assert
454  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
455  call_.PerformOps(&write_ops_);
456  }
457 
458  void Write(const W& msg, WriteOptions options, void* tag) override {
459  write_ops_.set_output_tag(tag);
460  if (options.is_last_message()) {
461  options.set_buffer_hint();
462  write_ops_.ClientSendClose();
463  }
464  // TODO(ctiller): don't assert
465  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
466  call_.PerformOps(&write_ops_);
467  }
468 
469  void WritesDone(void* tag) override {
470  write_ops_.set_output_tag(tag);
471  write_ops_.ClientSendClose();
472  call_.PerformOps(&write_ops_);
473  }
474 
479  void Finish(Status* status, void* tag) override {
480  finish_ops_.set_output_tag(tag);
481  if (!context_->initial_metadata_received_) {
482  finish_ops_.RecvInitialMetadata(context_);
483  }
484  finish_ops_.ClientRecvStatus(context_, status);
485  call_.PerformOps(&finish_ops_);
486  }
487 
488  private:
489  ClientAsyncReaderWriter(Call call, ClientContext* context, void* tag)
490  : context_(context), call_(call) {
491  if (context_->initial_metadata_corked_) {
492  // if corked bit is set in context, we buffer up the initial metadata to
493  // coalesce with later message to be sent. No op is performed.
494  write_ops_.SendInitialMetadata(context->send_initial_metadata_,
495  context->initial_metadata_flags());
496  } else {
497  write_ops_.set_output_tag(tag);
498  write_ops_.SendInitialMetadata(context->send_initial_metadata_,
499  context->initial_metadata_flags());
500  call_.PerformOps(&write_ops_);
501  }
502  }
503 
504  ClientContext* context_;
505  Call call_;
506  CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
507  CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> read_ops_;
508  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose>
509  write_ops_;
510  CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> finish_ops_;
511 };
512 
513 template <class W, class R>
515  public AsyncReaderInterface<R> {
516  public:
536  virtual void Finish(const W& msg, const Status& status, void* tag) = 0;
537 
556  virtual void FinishWithError(const Status& status, void* tag) = 0;
557 };
558 
562 template <class W, class R>
563 class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
564  public:
566  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
567 
573  void SendInitialMetadata(void* tag) override {
574  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
575 
576  meta_ops_.set_output_tag(tag);
577  meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
578  ctx_->initial_metadata_flags());
579  if (ctx_->compression_level_set()) {
580  meta_ops_.set_compression_level(ctx_->compression_level());
581  }
582  ctx_->sent_initial_metadata_ = true;
583  call_.PerformOps(&meta_ops_);
584  }
585 
586  void Read(R* msg, void* tag) override {
587  read_ops_.set_output_tag(tag);
588  read_ops_.RecvMessage(msg);
589  call_.PerformOps(&read_ops_);
590  }
591 
600  void Finish(const W& msg, const Status& status, void* tag) override {
601  finish_ops_.set_output_tag(tag);
602  if (!ctx_->sent_initial_metadata_) {
603  finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
604  ctx_->initial_metadata_flags());
605  if (ctx_->compression_level_set()) {
606  finish_ops_.set_compression_level(ctx_->compression_level());
607  }
608  ctx_->sent_initial_metadata_ = true;
609  }
610  // The response is dropped if the status is not OK.
611  if (status.ok()) {
612  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_,
613  finish_ops_.SendMessage(msg));
614  } else {
615  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
616  }
617  call_.PerformOps(&finish_ops_);
618  }
619 
626  void FinishWithError(const Status& status, void* tag) override {
627  GPR_CODEGEN_ASSERT(!status.ok());
628  finish_ops_.set_output_tag(tag);
629  if (!ctx_->sent_initial_metadata_) {
630  finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
631  ctx_->initial_metadata_flags());
632  if (ctx_->compression_level_set()) {
633  finish_ops_.set_compression_level(ctx_->compression_level());
634  }
635  ctx_->sent_initial_metadata_ = true;
636  }
637  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
638  call_.PerformOps(&finish_ops_);
639  }
640 
641  private:
642  void BindCall(Call* call) override { call_ = *call; }
643 
644  Call call_;
645  ServerContext* ctx_;
646  CallOpSet<CallOpSendInitialMetadata> meta_ops_;
647  CallOpSet<CallOpRecvMessage<R>> read_ops_;
648  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
649  CallOpServerSendStatus>
650  finish_ops_;
651 };
652 
653 template <class W>
655  public AsyncWriterInterface<W> {
656  public:
675  virtual void Finish(const Status& status, void* tag) = 0;
676 
688  virtual void WriteAndFinish(const W& msg, WriteOptions options,
689  const Status& status, void* tag) = 0;
690 };
691 
694 template <class W>
696  public:
698  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
699 
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 Write(const W& msg, void* tag) override {
721  write_ops_.set_output_tag(tag);
722  EnsureInitialMetadataSent(&write_ops_);
723  // TODO(ctiller): don't assert
724  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
725  call_.PerformOps(&write_ops_);
726  }
727 
728  void Write(const W& msg, WriteOptions options, void* tag) override {
729  write_ops_.set_output_tag(tag);
730  if (options.is_last_message()) {
731  options.set_buffer_hint();
732  }
733 
734  EnsureInitialMetadataSent(&write_ops_);
735  // TODO(ctiller): don't assert
736  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
737  call_.PerformOps(&write_ops_);
738  }
739 
747  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
748  void* tag) override {
749  write_ops_.set_output_tag(tag);
750  EnsureInitialMetadataSent(&write_ops_);
751  options.set_buffer_hint();
752  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
753  write_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
754  call_.PerformOps(&write_ops_);
755  }
756 
765  void Finish(const Status& status, void* tag) override {
766  finish_ops_.set_output_tag(tag);
767  EnsureInitialMetadataSent(&finish_ops_);
768  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
769  call_.PerformOps(&finish_ops_);
770  }
771 
772  private:
773  void BindCall(Call* call) override { call_ = *call; }
774 
775  template <class T>
776  void EnsureInitialMetadataSent(T* ops) {
777  if (!ctx_->sent_initial_metadata_) {
778  ops->SendInitialMetadata(ctx_->initial_metadata_,
779  ctx_->initial_metadata_flags());
780  if (ctx_->compression_level_set()) {
781  ops->set_compression_level(ctx_->compression_level());
782  }
783  ctx_->sent_initial_metadata_ = true;
784  }
785  }
786 
787  Call call_;
788  ServerContext* ctx_;
789  CallOpSet<CallOpSendInitialMetadata> meta_ops_;
790  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
791  CallOpServerSendStatus>
792  write_ops_;
793  CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> finish_ops_;
794 };
795 
797 template <class W, class R>
799  public AsyncWriterInterface<W>,
800  public AsyncReaderInterface<R> {
801  public:
821  virtual void Finish(const Status& status, void* tag) = 0;
822 
834  virtual void WriteAndFinish(const W& msg, WriteOptions options,
835  const Status& status, void* tag) = 0;
836 };
837 
842 template <class W, class R>
844  : public ServerAsyncReaderWriterInterface<W, R> {
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 Read(R* msg, void* tag) override {
870  read_ops_.set_output_tag(tag);
871  read_ops_.RecvMessage(msg);
872  call_.PerformOps(&read_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  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
880  call_.PerformOps(&write_ops_);
881  }
882 
883  void Write(const W& msg, 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  EnsureInitialMetadataSent(&write_ops_);
889  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
890  call_.PerformOps(&write_ops_);
891  }
892 
901  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
902  void* tag) override {
903  write_ops_.set_output_tag(tag);
904  EnsureInitialMetadataSent(&write_ops_);
905  options.set_buffer_hint();
906  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
907  write_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
908  call_.PerformOps(&write_ops_);
909  }
910 
919  void Finish(const Status& status, void* tag) override {
920  finish_ops_.set_output_tag(tag);
921  EnsureInitialMetadataSent(&finish_ops_);
922 
923  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
924  call_.PerformOps(&finish_ops_);
925  }
926 
927  private:
928  friend class ::grpc::Server;
929 
930  void BindCall(Call* call) override { call_ = *call; }
931 
932  template <class T>
933  void EnsureInitialMetadataSent(T* ops) {
934  if (!ctx_->sent_initial_metadata_) {
935  ops->SendInitialMetadata(ctx_->initial_metadata_,
936  ctx_->initial_metadata_flags());
937  if (ctx_->compression_level_set()) {
938  ops->set_compression_level(ctx_->compression_level());
939  }
940  ctx_->sent_initial_metadata_ = true;
941  }
942  }
943 
944  Call call_;
945  ServerContext* ctx_;
946  CallOpSet<CallOpSendInitialMetadata> meta_ops_;
947  CallOpSet<CallOpRecvMessage<R>> read_ops_;
948  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
949  CallOpServerSendStatus>
950  write_ops_;
951  CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> finish_ops_;
952 };
953 
954 } // namespace grpc
955 
956 #endif // GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H
Common interface for all client side asynchronous streaming.
Definition: async_stream.h:49
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: async_stream.h:403
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context.h:184
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:586
static ClientAsyncReaderWriter * Create(ChannelInterface *channel, CompletionQueue *cq, const RpcMethod &method, ClientContext *context, void *tag)
Create a stream and write the first request out.
Definition: async_stream.h:411
WriteOptions & set_buffer_hint()
Sets flag indicating that the write may be buffered and need not go out on the wire immediately...
Definition: call.h:136
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:211
virtual void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag)=0
Request the writing of msg and coalesce it with trailing metadata which contains status, using WriteOptions options with identifying tag tag.
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call.h:175
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:137
virtual void WritesDone(void *tag)=0
Signal the client is done with the writes (half-close the client stream).
virtual void Write(const W &msg, void *tag)=0
Request the writing of msg with identifying tag tag.
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: async_stream.h:843
static ClientAsyncReader * Create(ChannelInterface *channel, CompletionQueue *cq, const RpcMethod &method, ClientContext *context, const W &request, void *tag)
Create a stream and write the first request out.
Definition: async_stream.h:180
void FinishWithError(const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:626
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:883
Definition: service_type.h:53
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:479
Definition: async_stream.h:514
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:159
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:225
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:168
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:720
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: async_stream.h:695
void Finish(const W &msg, const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:600
void Finish(const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream.h:919
virtual ~AsyncReaderInterface()
Definition: async_stream.h:95
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:458
ServerAsyncReaderWriter(ServerContext *ctx)
Definition: async_stream.h:846
Definition: async_stream.h:165
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:856
Straightforward wrapping of the C call object.
Definition: call.h:638
Async client-side interface for bi-directional streaming, where the client-to-server message stream h...
Definition: async_stream.h:387
virtual void Finish(const Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
Codegen interface for grpc::Channel.
Definition: channel_interface.h:64
ServerAsyncWriter(ServerContext *ctx)
Definition: async_stream.h:697
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:64
An interface that can be fed a sequence of messages of type W.
Definition: async_stream.h:115
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:707
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: async_stream.h:273
virtual void FinishWithError(const Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain non-OK status code.
Server-side interface for asynchronous bi-directional streaming.
Definition: async_stream.h:798
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:469
A ServerContext allows the person implementing a service handler to:
Definition: server_context.h:109
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:573
Per-message write options.
Definition: call.h:96
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:728
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:314
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:901
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:101
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:51
virtual void * grpc_call_arena_alloc(grpc_call *call, size_t length)=0
virtual void ReadInitialMetadata(void *tag)=0
Request notification of the reading of the initial metadata.
Descriptor of an RPC method.
Definition: rpc_method.h:44
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:203
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:654
bool ok() const
Is the status OK?
Definition: status.h:76
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:321
Did it work? If it didn't, why?
Definition: status.h:45
void Finish(const Status &status, void *tag) override
See the ServerAsyncWriterInterface.Finish method for semantics.
Definition: async_stream.h:765
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method...
Definition: async_stream.h:434
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...
Definition: async_stream.h:654
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:345
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:332
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:451
grpc_call * call() const
Definition: call.h:658
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: async_stream.h:172
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:869
virtual ~AsyncWriterInterface()
Definition: async_stream.h:117
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:199
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:875
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:442
virtual void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag)=0
Request the writing of msg and coalesce it with trailing metadata which contains status, using WriteOptions options with identifying tag tag.
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:747
static ClientAsyncWriter * Create(ChannelInterface *channel, CompletionQueue *cq, const RpcMethod &method, ClientContext *context, R *response, void *tag)
Create a stream and write the first request out.
Definition: async_stream.h:284
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: async_stream.h:563
virtual void Finish(const Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code.
virtual void Read(R *msg, void *tag)=0
Read a message of type R into msg.
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:306
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.h:191
ServerAsyncReader(ServerContext *ctx)
Definition: async_stream.h:565
An interface that yields a sequence of messages of type R.
Definition: async_stream.h:93
virtual void Finish(const W &msg, const Status &status, void *tag)=0
Indicate that the stream is to be finished with a certain status code and also send out msg response ...
Common interface for client side asynchronous writing.
Definition: async_stream.h:259