GRPC C++  1.6.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 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 GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H
20 #define GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H
21 
28 
29 namespace grpc {
30 
31 class CompletionQueue;
32 
35  public:
37 
44  virtual void ReadInitialMetadata(void* tag) = 0;
45 
73  virtual void Finish(Status* status, void* tag) = 0;
74 };
75 
77 template <class R>
79  public:
80  virtual ~AsyncReaderInterface() {}
81 
95  virtual void Read(R* msg, void* tag) = 0;
96 };
97 
99 template <class W>
101  public:
103 
113  virtual void Write(const W& msg, void* tag) = 0;
114 
127  virtual void Write(const W& msg, WriteOptions options, void* tag) = 0;
128 
144  void WriteLast(const W& msg, WriteOptions options, void* tag) {
145  Write(msg, options.set_last_message(), tag);
146  }
147 };
148 
149 template <class R>
151  public AsyncReaderInterface<R> {};
152 
156 template <class R>
158  public:
164  template <class W>
166  CompletionQueue* cq, const RpcMethod& method,
167  ClientContext* context, const W& request,
168  void* tag) {
169  Call call = channel->CreateCall(method, context, cq);
171  call.call(), sizeof(ClientAsyncReader)))
172  ClientAsyncReader(call, context, request, tag);
173  }
174 
175  // always allocated against a call arena, no memory free required
176  static void operator delete(void* ptr, std::size_t size) {
177  assert(size == sizeof(ClientAsyncReader));
178  }
179 
188  void ReadInitialMetadata(void* tag) override {
189  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
190 
191  meta_ops_.set_output_tag(tag);
192  meta_ops_.RecvInitialMetadata(context_);
193  call_.PerformOps(&meta_ops_);
194  }
195 
196  void Read(R* msg, void* tag) override {
197  read_ops_.set_output_tag(tag);
198  if (!context_->initial_metadata_received_) {
199  read_ops_.RecvInitialMetadata(context_);
200  }
201  read_ops_.RecvMessage(msg);
202  call_.PerformOps(&read_ops_);
203  }
204 
210  void Finish(Status* status, void* tag) override {
211  finish_ops_.set_output_tag(tag);
212  if (!context_->initial_metadata_received_) {
213  finish_ops_.RecvInitialMetadata(context_);
214  }
215  finish_ops_.ClientRecvStatus(context_, status);
216  call_.PerformOps(&finish_ops_);
217  }
218 
219  private:
220  template <class W>
221  ClientAsyncReader(Call call, ClientContext* context, const W& request,
222  void* tag)
223  : context_(context), call_(call) {
224  init_ops_.set_output_tag(tag);
225  init_ops_.SendInitialMetadata(context->send_initial_metadata_,
226  context->initial_metadata_flags());
227  // TODO(ctiller): don't assert
228  GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok());
229  init_ops_.ClientSendClose();
230  call_.PerformOps(&init_ops_);
231  }
232 
233  ClientContext* context_;
234  Call call_;
235  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose>
236  init_ops_;
237  CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
238  CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> read_ops_;
239  CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> finish_ops_;
240 };
241 
243 template <class W>
245  public AsyncWriterInterface<W> {
246  public:
251  virtual void WritesDone(void* tag) = 0;
252 };
253 
257 template <class W>
259  public:
268  template <class R>
270  CompletionQueue* cq, const RpcMethod& method,
271  ClientContext* context, R* response,
272  void* tag) {
273  Call call = channel->CreateCall(method, context, cq);
275  call.call(), sizeof(ClientAsyncWriter)))
276  ClientAsyncWriter(call, context, response, tag);
277  }
278 
279  // always allocated against a call arena, no memory free required
280  static void operator delete(void* ptr, std::size_t size) {
281  assert(size == sizeof(ClientAsyncWriter));
282  }
283 
291  void ReadInitialMetadata(void* tag) override {
292  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
293 
294  meta_ops_.set_output_tag(tag);
295  meta_ops_.RecvInitialMetadata(context_);
296  call_.PerformOps(&meta_ops_);
297  }
298 
299  void Write(const W& msg, void* tag) override {
300  write_ops_.set_output_tag(tag);
301  // TODO(ctiller): don't assert
302  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
303  call_.PerformOps(&write_ops_);
304  }
305 
306  void Write(const W& msg, WriteOptions options, void* tag) override {
307  write_ops_.set_output_tag(tag);
308  if (options.is_last_message()) {
309  options.set_buffer_hint();
310  write_ops_.ClientSendClose();
311  }
312  // TODO(ctiller): don't assert
313  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
314  call_.PerformOps(&write_ops_);
315  }
316 
317  void WritesDone(void* tag) override {
318  write_ops_.set_output_tag(tag);
319  write_ops_.ClientSendClose();
320  call_.PerformOps(&write_ops_);
321  }
322 
330  void Finish(Status* status, void* tag) override {
331  finish_ops_.set_output_tag(tag);
332  if (!context_->initial_metadata_received_) {
333  finish_ops_.RecvInitialMetadata(context_);
334  }
335  finish_ops_.ClientRecvStatus(context_, status);
336  call_.PerformOps(&finish_ops_);
337  }
338 
339  private:
340  template <class R>
341  ClientAsyncWriter(Call call, ClientContext* context, R* response, void* tag)
342  : context_(context), call_(call) {
343  finish_ops_.RecvMessage(response);
344  finish_ops_.AllowNoMessage();
345  // if corked bit is set in context, we buffer up the initial metadata to
346  // coalesce with later message to be sent. No op is performed.
347  if (context_->initial_metadata_corked_) {
348  write_ops_.SendInitialMetadata(context->send_initial_metadata_,
349  context->initial_metadata_flags());
350  } else {
351  write_ops_.set_output_tag(tag);
352  write_ops_.SendInitialMetadata(context->send_initial_metadata_,
353  context->initial_metadata_flags());
354  call_.PerformOps(&write_ops_);
355  }
356  }
357 
358  ClientContext* context_;
359  Call call_;
360  CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
361  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose>
362  write_ops_;
363  CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage,
364  CallOpClientRecvStatus>
365  finish_ops_;
366 };
367 
371 template <class W, class R>
373  public AsyncWriterInterface<W>,
374  public AsyncReaderInterface<R> {
375  public:
380  virtual void WritesDone(void* tag) = 0;
381 };
382 
387 template <class W, class R>
389  : public ClientAsyncReaderWriterInterface<W, R> {
390  public:
397  CompletionQueue* cq,
398  const RpcMethod& method,
399  ClientContext* context, void* tag) {
400  Call call = channel->CreateCall(method, context, cq);
401 
403  call.call(), sizeof(ClientAsyncReaderWriter)))
404  ClientAsyncReaderWriter(call, context, tag);
405  }
406 
407  // always allocated against a call arena, no memory free required
408  static void operator delete(void* ptr, std::size_t size) {
409  assert(size == sizeof(ClientAsyncReaderWriter));
410  }
411 
419  void ReadInitialMetadata(void* tag) override {
420  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
421 
422  meta_ops_.set_output_tag(tag);
423  meta_ops_.RecvInitialMetadata(context_);
424  call_.PerformOps(&meta_ops_);
425  }
426 
427  void Read(R* msg, void* tag) override {
428  read_ops_.set_output_tag(tag);
429  if (!context_->initial_metadata_received_) {
430  read_ops_.RecvInitialMetadata(context_);
431  }
432  read_ops_.RecvMessage(msg);
433  call_.PerformOps(&read_ops_);
434  }
435 
436  void Write(const W& msg, void* tag) override {
437  write_ops_.set_output_tag(tag);
438  // TODO(ctiller): don't assert
439  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
440  call_.PerformOps(&write_ops_);
441  }
442 
443  void Write(const W& msg, WriteOptions options, void* tag) override {
444  write_ops_.set_output_tag(tag);
445  if (options.is_last_message()) {
446  options.set_buffer_hint();
447  write_ops_.ClientSendClose();
448  }
449  // TODO(ctiller): don't assert
450  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
451  call_.PerformOps(&write_ops_);
452  }
453 
454  void WritesDone(void* tag) override {
455  write_ops_.set_output_tag(tag);
456  write_ops_.ClientSendClose();
457  call_.PerformOps(&write_ops_);
458  }
459 
464  void Finish(Status* status, void* tag) override {
465  finish_ops_.set_output_tag(tag);
466  if (!context_->initial_metadata_received_) {
467  finish_ops_.RecvInitialMetadata(context_);
468  }
469  finish_ops_.ClientRecvStatus(context_, status);
470  call_.PerformOps(&finish_ops_);
471  }
472 
473  private:
474  ClientAsyncReaderWriter(Call call, ClientContext* context, void* tag)
475  : context_(context), call_(call) {
476  if (context_->initial_metadata_corked_) {
477  // if corked bit is set in context, we buffer up the initial metadata to
478  // coalesce with later message to be sent. No op is performed.
479  write_ops_.SendInitialMetadata(context->send_initial_metadata_,
480  context->initial_metadata_flags());
481  } else {
482  write_ops_.set_output_tag(tag);
483  write_ops_.SendInitialMetadata(context->send_initial_metadata_,
484  context->initial_metadata_flags());
485  call_.PerformOps(&write_ops_);
486  }
487  }
488 
489  ClientContext* context_;
490  Call call_;
491  CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
492  CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> read_ops_;
493  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose>
494  write_ops_;
495  CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> finish_ops_;
496 };
497 
498 template <class W, class R>
500  public AsyncReaderInterface<R> {
501  public:
521  virtual void Finish(const W& msg, const Status& status, void* tag) = 0;
522 
541  virtual void FinishWithError(const Status& status, void* tag) = 0;
542 };
543 
547 template <class W, class R>
548 class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
549  public:
551  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
552 
558  void SendInitialMetadata(void* tag) override {
559  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
560 
561  meta_ops_.set_output_tag(tag);
562  meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
563  ctx_->initial_metadata_flags());
564  if (ctx_->compression_level_set()) {
565  meta_ops_.set_compression_level(ctx_->compression_level());
566  }
567  ctx_->sent_initial_metadata_ = true;
568  call_.PerformOps(&meta_ops_);
569  }
570 
571  void Read(R* msg, void* tag) override {
572  read_ops_.set_output_tag(tag);
573  read_ops_.RecvMessage(msg);
574  call_.PerformOps(&read_ops_);
575  }
576 
585  void Finish(const W& msg, const Status& status, void* tag) override {
586  finish_ops_.set_output_tag(tag);
587  if (!ctx_->sent_initial_metadata_) {
588  finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
589  ctx_->initial_metadata_flags());
590  if (ctx_->compression_level_set()) {
591  finish_ops_.set_compression_level(ctx_->compression_level());
592  }
593  ctx_->sent_initial_metadata_ = true;
594  }
595  // The response is dropped if the status is not OK.
596  if (status.ok()) {
597  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_,
598  finish_ops_.SendMessage(msg));
599  } else {
600  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
601  }
602  call_.PerformOps(&finish_ops_);
603  }
604 
611  void FinishWithError(const Status& status, void* tag) override {
612  GPR_CODEGEN_ASSERT(!status.ok());
613  finish_ops_.set_output_tag(tag);
614  if (!ctx_->sent_initial_metadata_) {
615  finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
616  ctx_->initial_metadata_flags());
617  if (ctx_->compression_level_set()) {
618  finish_ops_.set_compression_level(ctx_->compression_level());
619  }
620  ctx_->sent_initial_metadata_ = true;
621  }
622  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
623  call_.PerformOps(&finish_ops_);
624  }
625 
626  private:
627  void BindCall(Call* call) override { call_ = *call; }
628 
629  Call call_;
630  ServerContext* ctx_;
631  CallOpSet<CallOpSendInitialMetadata> meta_ops_;
632  CallOpSet<CallOpRecvMessage<R>> read_ops_;
633  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
634  CallOpServerSendStatus>
635  finish_ops_;
636 };
637 
638 template <class W>
640  public AsyncWriterInterface<W> {
641  public:
660  virtual void Finish(const Status& status, void* tag) = 0;
661 
673  virtual void WriteAndFinish(const W& msg, WriteOptions options,
674  const Status& status, void* tag) = 0;
675 };
676 
679 template <class W>
681  public:
683  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
684 
692  void SendInitialMetadata(void* tag) override {
693  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
694 
695  meta_ops_.set_output_tag(tag);
696  meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
697  ctx_->initial_metadata_flags());
698  if (ctx_->compression_level_set()) {
699  meta_ops_.set_compression_level(ctx_->compression_level());
700  }
701  ctx_->sent_initial_metadata_ = true;
702  call_.PerformOps(&meta_ops_);
703  }
704 
705  void Write(const W& msg, void* tag) override {
706  write_ops_.set_output_tag(tag);
707  EnsureInitialMetadataSent(&write_ops_);
708  // TODO(ctiller): don't assert
709  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
710  call_.PerformOps(&write_ops_);
711  }
712 
713  void Write(const W& msg, WriteOptions options, void* tag) override {
714  write_ops_.set_output_tag(tag);
715  if (options.is_last_message()) {
716  options.set_buffer_hint();
717  }
718 
719  EnsureInitialMetadataSent(&write_ops_);
720  // TODO(ctiller): don't assert
721  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
722  call_.PerformOps(&write_ops_);
723  }
724 
732  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
733  void* tag) override {
734  write_ops_.set_output_tag(tag);
735  EnsureInitialMetadataSent(&write_ops_);
736  options.set_buffer_hint();
737  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
738  write_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
739  call_.PerformOps(&write_ops_);
740  }
741 
750  void Finish(const Status& status, void* tag) override {
751  finish_ops_.set_output_tag(tag);
752  EnsureInitialMetadataSent(&finish_ops_);
753  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
754  call_.PerformOps(&finish_ops_);
755  }
756 
757  private:
758  void BindCall(Call* call) override { call_ = *call; }
759 
760  template <class T>
761  void EnsureInitialMetadataSent(T* ops) {
762  if (!ctx_->sent_initial_metadata_) {
763  ops->SendInitialMetadata(ctx_->initial_metadata_,
764  ctx_->initial_metadata_flags());
765  if (ctx_->compression_level_set()) {
766  ops->set_compression_level(ctx_->compression_level());
767  }
768  ctx_->sent_initial_metadata_ = true;
769  }
770  }
771 
772  Call call_;
773  ServerContext* ctx_;
774  CallOpSet<CallOpSendInitialMetadata> meta_ops_;
775  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
776  CallOpServerSendStatus>
777  write_ops_;
778  CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> finish_ops_;
779 };
780 
782 template <class W, class R>
784  public AsyncWriterInterface<W>,
785  public AsyncReaderInterface<R> {
786  public:
806  virtual void Finish(const Status& status, void* tag) = 0;
807 
819  virtual void WriteAndFinish(const W& msg, WriteOptions options,
820  const Status& status, void* tag) = 0;
821 };
822 
827 template <class W, class R>
829  : public ServerAsyncReaderWriterInterface<W, R> {
830  public:
832  : call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
833 
841  void SendInitialMetadata(void* tag) override {
842  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
843 
844  meta_ops_.set_output_tag(tag);
845  meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
846  ctx_->initial_metadata_flags());
847  if (ctx_->compression_level_set()) {
848  meta_ops_.set_compression_level(ctx_->compression_level());
849  }
850  ctx_->sent_initial_metadata_ = true;
851  call_.PerformOps(&meta_ops_);
852  }
853 
854  void Read(R* msg, void* tag) override {
855  read_ops_.set_output_tag(tag);
856  read_ops_.RecvMessage(msg);
857  call_.PerformOps(&read_ops_);
858  }
859 
860  void Write(const W& msg, void* tag) override {
861  write_ops_.set_output_tag(tag);
862  EnsureInitialMetadataSent(&write_ops_);
863  // TODO(ctiller): don't assert
864  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
865  call_.PerformOps(&write_ops_);
866  }
867 
868  void Write(const W& msg, WriteOptions options, void* tag) override {
869  write_ops_.set_output_tag(tag);
870  if (options.is_last_message()) {
871  options.set_buffer_hint();
872  }
873  EnsureInitialMetadataSent(&write_ops_);
874  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
875  call_.PerformOps(&write_ops_);
876  }
877 
886  void WriteAndFinish(const W& msg, WriteOptions options, const Status& status,
887  void* tag) override {
888  write_ops_.set_output_tag(tag);
889  EnsureInitialMetadataSent(&write_ops_);
890  options.set_buffer_hint();
891  GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg, options).ok());
892  write_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
893  call_.PerformOps(&write_ops_);
894  }
895 
904  void Finish(const Status& status, void* tag) override {
905  finish_ops_.set_output_tag(tag);
906  EnsureInitialMetadataSent(&finish_ops_);
907 
908  finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
909  call_.PerformOps(&finish_ops_);
910  }
911 
912  private:
913  friend class ::grpc::Server;
914 
915  void BindCall(Call* call) override { call_ = *call; }
916 
917  template <class T>
918  void EnsureInitialMetadataSent(T* ops) {
919  if (!ctx_->sent_initial_metadata_) {
920  ops->SendInitialMetadata(ctx_->initial_metadata_,
921  ctx_->initial_metadata_flags());
922  if (ctx_->compression_level_set()) {
923  ops->set_compression_level(ctx_->compression_level());
924  }
925  ctx_->sent_initial_metadata_ = true;
926  }
927  }
928 
929  Call call_;
930  ServerContext* ctx_;
931  CallOpSet<CallOpSendInitialMetadata> meta_ops_;
932  CallOpSet<CallOpRecvMessage<R>> read_ops_;
933  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
934  CallOpServerSendStatus>
935  write_ops_;
936  CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> finish_ops_;
937 };
938 
939 } // namespace grpc
940 
941 #endif // GRPCXX_IMPL_CODEGEN_ASYNC_STREAM_H
Common interface for all client side asynchronous streaming.
Definition: async_stream.h:34
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: async_stream.h:388
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context.h:170
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:571
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:396
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:121
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:196
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:160
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:126
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:828
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:165
void FinishWithError(const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:611
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:868
Definition: service_type.h:38
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:464
Definition: async_stream.h:499
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:144
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:210
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:153
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:705
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: async_stream.h:680
void Finish(const W &msg, const Status &status, void *tag) override
See the ServerAsyncReaderInterface.Read method for semantics.
Definition: async_stream.h:585
void Finish(const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.Finish method for semantics.
Definition: async_stream.h:904
virtual ~AsyncReaderInterface()
Definition: async_stream.h:80
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:443
ServerAsyncReaderWriter(ServerContext *ctx)
Definition: async_stream.h:831
Definition: async_stream.h:150
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:841
Straightforward wrapping of the C call object.
Definition: call.h:647
Async client-side interface for bi-directional streaming, where the client-to-server message stream h...
Definition: async_stream.h:372
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:49
ServerAsyncWriter(ServerContext *ctx)
Definition: async_stream.h:682
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:49
An interface that can be fed a sequence of messages of type W.
Definition: async_stream.h:100
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:692
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: async_stream.h:258
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:783
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:454
A ServerContext allows the person implementing a service handler to:
Definition: server_context.h:95
void SendInitialMetadata(void *tag) override
See ServerAsyncStreamingInterface::SendInitialMetadata for semantics.
Definition: async_stream.h:558
Per-message write options.
Definition: call.h:81
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:713
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:299
void WriteAndFinish(const W &msg, WriteOptions options, const Status &status, void *tag) override
See the ServerAsyncReaderWriterInterface.WriteAndFinish method for semantics.
Definition: async_stream.h:886
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:86
virtual ~ClientAsyncStreamingInterface()
Definition: async_stream.h:36
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:29
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics.
Definition: async_stream.h:188
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:663
bool ok() const
Is the status OK?
Definition: status.h:64
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:306
Did it work? If it didn't, why?
Definition: status.h:30
void Finish(const Status &status, void *tag) override
See the ServerAsyncWriterInterface.Finish method for semantics.
Definition: async_stream.h:750
void ReadInitialMetadata(void *tag) override
See the ClientAsyncStreamingInterface.ReadInitialMetadata method for semantics of this method...
Definition: async_stream.h:419
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:639
void Finish(Status *status, void *tag) override
See the ClientAsyncStreamingInterface.Finish method for semantics.
Definition: async_stream.h:330
void WritesDone(void *tag) override
Signal the client is done with the writes (half-close the client stream).
Definition: async_stream.h:317
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:436
grpc_call * call() const
Definition: call.h:667
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: async_stream.h:157
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:854
virtual ~AsyncWriterInterface()
Definition: async_stream.h:102
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:185
void Write(const W &msg, void *tag) override
Request the writing of msg with identifying tag tag.
Definition: async_stream.h:860
void Read(R *msg, void *tag) override
Read a message of type R into msg.
Definition: async_stream.h:427
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:732
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:269
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: async_stream.h:548
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:291
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:176
ServerAsyncReader(ServerContext *ctx)
Definition: async_stream.h:550
An interface that yields a sequence of messages of type R.
Definition: async_stream.h:78
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:244