GRPC C++  1.6.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sync_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_SYNC_STREAM_H
20 #define GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H
21 
30 
31 namespace grpc {
32 
35  public:
37 
62  virtual Status Finish() = 0;
63 };
64 
67  public:
69 
76  virtual void SendInitialMetadata() = 0;
77 };
78 
80 template <class R>
82  public:
83  virtual ~ReaderInterface() {}
84 
87  virtual bool NextMessageSize(uint32_t* sz) = 0;
88 
99  virtual bool Read(R* msg) = 0;
100 };
101 
103 template <class W>
105  public:
106  virtual ~WriterInterface() {}
107 
115  virtual bool Write(const W& msg, WriteOptions options) = 0;
116 
123  inline bool Write(const W& msg) { return Write(msg, WriteOptions()); }
124 
139  void WriteLast(const W& msg, WriteOptions options) {
140  Write(msg, options.set_last_message());
141  }
142 };
143 
145 template <class R>
147  public ReaderInterface<R> {
148  public:
153  virtual void WaitForInitialMetadata() = 0;
154 };
155 
159 template <class R>
160 class ClientReader final : public ClientReaderInterface<R> {
161  public:
165  template <class W>
166  ClientReader(ChannelInterface* channel, const RpcMethod& method,
167  ClientContext* context, const W& request)
168  : context_(context),
171  GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
172  call_(channel->CreateCall(method, context, &cq_)) {
175  ops;
176  ops.SendInitialMetadata(context->send_initial_metadata_,
177  context->initial_metadata_flags());
178  // TODO(ctiller): don't assert
179  GPR_CODEGEN_ASSERT(ops.SendMessage(request).ok());
180  ops.ClientSendClose();
181  call_.PerformOps(&ops);
182  cq_.Pluck(&ops);
183  }
184 
188  // Side effect:
192  void WaitForInitialMetadata() override {
193  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
194 
196  ops.RecvInitialMetadata(context_);
197  call_.PerformOps(&ops);
198  cq_.Pluck(&ops);
199  }
200 
201  bool NextMessageSize(uint32_t* sz) override {
202  *sz = call_.max_receive_message_size();
203  return true;
204  }
205 
211  bool Read(R* msg) override {
213  if (!context_->initial_metadata_received_) {
214  ops.RecvInitialMetadata(context_);
215  }
216  ops.RecvMessage(msg);
217  call_.PerformOps(&ops);
218  return cq_.Pluck(&ops) && ops.got_message;
219  }
220 
226  Status Finish() override {
228  Status status;
229  ops.ClientRecvStatus(context_, &status);
230  call_.PerformOps(&ops);
231  GPR_CODEGEN_ASSERT(cq_.Pluck(&ops));
232  return status;
233  }
234 
235  private:
236  ClientContext* context_;
237  CompletionQueue cq_;
238  Call call_;
239 };
240 
242 template <class W>
244  public WriterInterface<W> {
245  public:
252  virtual bool WritesDone() = 0;
253 };
254 
258 template <class W>
259 class ClientWriter : public ClientWriterInterface<W> {
260  public:
266  template <class R>
267  ClientWriter(ChannelInterface* channel, const RpcMethod& method,
268  ClientContext* context, R* response)
269  : context_(context),
272  GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
273  call_(channel->CreateCall(method, context, &cq_)) {
274  finish_ops_.RecvMessage(response);
275  finish_ops_.AllowNoMessage();
276 
277  if (!context_->initial_metadata_corked_) {
279  ops.SendInitialMetadata(context->send_initial_metadata_,
280  context->initial_metadata_flags());
281  call_.PerformOps(&ops);
282  cq_.Pluck(&ops);
283  }
284  }
285 
289  // Side effect:
293  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
294 
296  ops.RecvInitialMetadata(context_);
297  call_.PerformOps(&ops);
298  cq_.Pluck(&ops); // status ignored
299  }
300 
308  bool Write(const W& msg, WriteOptions options) override {
309  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
311  ops;
312 
313  if (options.is_last_message()) {
314  options.set_buffer_hint();
315  ops.ClientSendClose();
316  }
317  if (context_->initial_metadata_corked_) {
318  ops.SendInitialMetadata(context_->send_initial_metadata_,
319  context_->initial_metadata_flags());
320  context_->set_initial_metadata_corked(false);
321  }
322  if (!ops.SendMessage(msg, options).ok()) {
323  return false;
324  }
325 
326  call_.PerformOps(&ops);
327  return cq_.Pluck(&ops);
328  }
329 
330  bool WritesDone() override {
332  ops.ClientSendClose();
333  call_.PerformOps(&ops);
334  return cq_.Pluck(&ops);
335  }
336 
343  Status Finish() override {
344  Status status;
345  if (!context_->initial_metadata_received_) {
346  finish_ops_.RecvInitialMetadata(context_);
347  }
348  finish_ops_.ClientRecvStatus(context_, &status);
349  call_.PerformOps(&finish_ops_);
350  GPR_CODEGEN_ASSERT(cq_.Pluck(&finish_ops_));
351  return status;
352  }
353 
354  private:
355  ClientContext* context_;
358  finish_ops_;
359  CompletionQueue cq_;
360  Call call_;
361 };
362 
366 template <class W, class R>
368  public WriterInterface<W>,
369  public ReaderInterface<R> {
370  public:
375  virtual void WaitForInitialMetadata() = 0;
376 
383  virtual bool WritesDone() = 0;
384 };
385 
390 template <class W, class R>
391 class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
392  public:
397  ClientContext* context)
398  : context_(context),
401  GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
402  call_(channel->CreateCall(method, context, &cq_)) {
403  if (!context_->initial_metadata_corked_) {
405  ops.SendInitialMetadata(context->send_initial_metadata_,
406  context->initial_metadata_flags());
407  call_.PerformOps(&ops);
408  cq_.Pluck(&ops);
409  }
410  }
411 
418  void WaitForInitialMetadata() override {
419  GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
420 
422  ops.RecvInitialMetadata(context_);
423  call_.PerformOps(&ops);
424  cq_.Pluck(&ops); // status ignored
425  }
426 
427  bool NextMessageSize(uint32_t* sz) override {
428  *sz = call_.max_receive_message_size();
429  return true;
430  }
431 
436  bool Read(R* msg) override {
438  if (!context_->initial_metadata_received_) {
439  ops.RecvInitialMetadata(context_);
440  }
441  ops.RecvMessage(msg);
442  call_.PerformOps(&ops);
443  return cq_.Pluck(&ops) && ops.got_message;
444  }
445 
452  bool Write(const W& msg, WriteOptions options) override {
453  CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
455  ops;
456 
457  if (options.is_last_message()) {
458  options.set_buffer_hint();
459  ops.ClientSendClose();
460  }
461  if (context_->initial_metadata_corked_) {
462  ops.SendInitialMetadata(context_->send_initial_metadata_,
463  context_->initial_metadata_flags());
464  context_->set_initial_metadata_corked(false);
465  }
466  if (!ops.SendMessage(msg, options).ok()) {
467  return false;
468  }
469 
470  call_.PerformOps(&ops);
471  return cq_.Pluck(&ops);
472  }
473 
474  bool WritesDone() override {
476  ops.ClientSendClose();
477  call_.PerformOps(&ops);
478  return cq_.Pluck(&ops);
479  }
480 
486  Status Finish() override {
488  if (!context_->initial_metadata_received_) {
489  ops.RecvInitialMetadata(context_);
490  }
491  Status status;
492  ops.ClientRecvStatus(context_, &status);
493  call_.PerformOps(&ops);
494  GPR_CODEGEN_ASSERT(cq_.Pluck(&ops));
495  return status;
496  }
497 
498  private:
499  ClientContext* context_;
500  CompletionQueue cq_;
501  Call call_;
502 };
503 
505 template <class R>
507  public ReaderInterface<R> {};
508 
512 template <class R>
513 class ServerReader final : public ServerReaderInterface<R> {
514  public:
515  ServerReader(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {}
516 
520  void SendInitialMetadata() override {
521  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
522 
524  ops.SendInitialMetadata(ctx_->initial_metadata_,
525  ctx_->initial_metadata_flags());
526  if (ctx_->compression_level_set()) {
527  ops.set_compression_level(ctx_->compression_level());
528  }
529  ctx_->sent_initial_metadata_ = true;
530  call_->PerformOps(&ops);
531  call_->cq()->Pluck(&ops);
532  }
533 
534  bool NextMessageSize(uint32_t* sz) override {
535  *sz = call_->max_receive_message_size();
536  return true;
537  }
538 
539  bool Read(R* msg) override {
541  ops.RecvMessage(msg);
542  call_->PerformOps(&ops);
543  return call_->cq()->Pluck(&ops) && ops.got_message;
544  }
545 
546  private:
547  Call* const call_;
548  ServerContext* const ctx_;
549 };
550 
552 template <class W>
554  public WriterInterface<W> {};
555 
559 template <class W>
560 class ServerWriter final : public ServerWriterInterface<W> {
561  public:
562  ServerWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {}
563 
568  void SendInitialMetadata() override {
569  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
570 
572  ops.SendInitialMetadata(ctx_->initial_metadata_,
573  ctx_->initial_metadata_flags());
574  if (ctx_->compression_level_set()) {
575  ops.set_compression_level(ctx_->compression_level());
576  }
577  ctx_->sent_initial_metadata_ = true;
578  call_->PerformOps(&ops);
579  call_->cq()->Pluck(&ops);
580  }
581 
588  bool Write(const W& msg, WriteOptions options) override {
589  if (options.is_last_message()) {
590  options.set_buffer_hint();
591  }
592  if (!ctx_->pending_ops_.SendMessage(msg, options).ok()) {
593  return false;
594  }
595  if (!ctx_->sent_initial_metadata_) {
596  ctx_->pending_ops_.SendInitialMetadata(ctx_->initial_metadata_,
597  ctx_->initial_metadata_flags());
598  if (ctx_->compression_level_set()) {
599  ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
600  }
601  ctx_->sent_initial_metadata_ = true;
602  }
603  call_->PerformOps(&ctx_->pending_ops_);
604  // if this is the last message we defer the pluck until AFTER we start
605  // the trailing md op. This prevents hangs. See
606  // https://github.com/grpc/grpc/issues/11546
607  if (options.is_last_message()) {
608  ctx_->has_pending_ops_ = true;
609  return true;
610  }
611  ctx_->has_pending_ops_ = false;
612  return call_->cq()->Pluck(&ctx_->pending_ops_);
613  }
614 
615  private:
616  Call* const call_;
617  ServerContext* const ctx_;
618 };
619 
621 template <class W, class R>
623  public WriterInterface<W>,
624  public ReaderInterface<R> {};
625 
627 namespace internal {
628 template <class W, class R>
629 class ServerReaderWriterBody final {
630  public:
632  : call_(call), ctx_(ctx) {}
633 
635  GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
636 
638  ops.SendInitialMetadata(ctx_->initial_metadata_,
639  ctx_->initial_metadata_flags());
640  if (ctx_->compression_level_set()) {
641  ops.set_compression_level(ctx_->compression_level());
642  }
643  ctx_->sent_initial_metadata_ = true;
644  call_->PerformOps(&ops);
645  call_->cq()->Pluck(&ops);
646  }
647 
648  bool NextMessageSize(uint32_t* sz) {
649  *sz = call_->max_receive_message_size();
650  return true;
651  }
652 
653  bool Read(R* msg) {
655  ops.RecvMessage(msg);
656  call_->PerformOps(&ops);
657  return call_->cq()->Pluck(&ops) && ops.got_message;
658  }
659 
660  bool Write(const W& msg, WriteOptions options) {
661  if (options.is_last_message()) {
662  options.set_buffer_hint();
663  }
664  if (!ctx_->pending_ops_.SendMessage(msg, options).ok()) {
665  return false;
666  }
667  if (!ctx_->sent_initial_metadata_) {
668  ctx_->pending_ops_.SendInitialMetadata(ctx_->initial_metadata_,
669  ctx_->initial_metadata_flags());
670  if (ctx_->compression_level_set()) {
671  ctx_->pending_ops_.set_compression_level(ctx_->compression_level());
672  }
673  ctx_->sent_initial_metadata_ = true;
674  }
675  call_->PerformOps(&ctx_->pending_ops_);
676  // if this is the last message we defer the pluck until AFTER we start
677  // the trailing md op. This prevents hangs. See
678  // https://github.com/grpc/grpc/issues/11546
679  if (options.is_last_message()) {
680  ctx_->has_pending_ops_ = true;
681  return true;
682  }
683  ctx_->has_pending_ops_ = false;
684  return call_->cq()->Pluck(&ctx_->pending_ops_);
685  }
686 
687  private:
688  Call* const call_;
689  ServerContext* const ctx_;
690 };
691 } // namespace internal
692 
697 template <class W, class R>
699  public:
700  ServerReaderWriter(Call* call, ServerContext* ctx) : body_(call, ctx) {}
701 
705  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
706 
707  bool NextMessageSize(uint32_t* sz) override {
708  return body_.NextMessageSize(sz);
709  }
710 
711  bool Read(R* msg) override { return body_.Read(msg); }
712 
719  bool Write(const W& msg, WriteOptions options) override {
720  return body_.Write(msg, options);
721  }
722 
723  private:
725 };
726 
735 template <class RequestType, class ResponseType>
737  : public ServerReaderWriterInterface<ResponseType, RequestType> {
738  public:
740  : body_(call, ctx), read_done_(false), write_done_(false) {}
741 
746  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
747 
749  bool NextMessageSize(uint32_t* sz) override {
750  return body_.NextMessageSize(sz);
751  }
752 
763  bool Read(RequestType* request) override {
764  if (read_done_) {
765  return false;
766  }
767  read_done_ = true;
768  return body_.Read(request);
769  }
770 
779  bool Write(const ResponseType& response, WriteOptions options) override {
780  if (write_done_ || !read_done_) {
781  return false;
782  }
783  write_done_ = true;
784  return body_.Write(response, options);
785  }
786 
787  private:
789  bool read_done_;
790  bool write_done_;
791 };
792 
798 template <class RequestType, class ResponseType>
800  : public ServerReaderWriterInterface<ResponseType, RequestType> {
801  public:
803  : body_(call, ctx), read_done_(false) {}
804 
809  void SendInitialMetadata() override { body_.SendInitialMetadata(); }
810 
812  bool NextMessageSize(uint32_t* sz) override {
813  return body_.NextMessageSize(sz);
814  }
815 
826  bool Read(RequestType* request) override {
827  if (read_done_) {
828  return false;
829  }
830  read_done_ = true;
831  return body_.Read(request);
832  }
833 
842  bool Write(const ResponseType& response, WriteOptions options) override {
843  return read_done_ && body_.Write(response, options);
844  }
845 
846  private:
848  bool read_done_;
849 };
850 
851 } // namespace grpc
852 
853 #endif // GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: channel_interface.h:34
Client-side interface for streaming writes of message type W.
Definition: sync_stream.h:243
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context.h:170
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
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream.h:711
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
Common interface for all synchronous server side streaming.
Definition: sync_stream.h:66
bool Write(const W &msg, WriteOptions options)
Definition: sync_stream.h:660
Server-side interface for bi-directional streaming.
Definition: sync_stream.h:622
A class to represent a flow-controlled server-side streaming call.
Definition: sync_stream.h:799
ServerReaderWriterBody(Call *call, ServerContext *ctx)
Definition: sync_stream.h:631
bool NextMessageSize(uint32_t *sz)
Definition: sync_stream.h:648
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:427
Client-side interface for streaming reads of message of type R.
Definition: sync_stream.h:146
Definition: completion_queue.h:58
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
virtual ~ServerStreamingInterface()
Definition: sync_stream.h:68
An interface that yields a sequence of messages of type R.
Definition: sync_stream.h:81
bool Write(const ResponseType &response, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:779
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:126
Definition: call.h:524
A class to represent a flow-controlled unary call.
Definition: sync_stream.h:736
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:211
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:520
virtual ~ReaderInterface()
Definition: sync_stream.h:83
void set_initial_metadata_corked(bool corked)
Flag whether the initial metadata should be corked.
Definition: client_context.h:300
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:809
bool Read(R *msg)
Definition: sync_stream.h:653
#define GRPC_CQ_CURRENT_VERSION
Definition: grpc_types.h:600
Server-side interface for streaming reads of message of type R.
Definition: sync_stream.h:506
Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:226
bool Read(R *msg) override
Block to read a message and parse to msg.
Definition: sync_stream.h:539
bool Write(const ResponseType &response, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:842
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream.h:330
bool Read(R *msg) override
See the ReaderInterface.Read method for semantics.
Definition: sync_stream.h:436
Definition: grpc_types.h:601
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:153
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:53
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:201
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:452
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream.h:812
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:705
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:707
void SendInitialMetadata()
Definition: sync_stream.h:634
void SendInitialMetadata() override
See the ServerStreamingInterface.SendInitialMetadata method for semantics.
Definition: sync_stream.h:568
Definition: call.h:256
ServerReader(Call *call, ServerContext *ctx)
Definition: sync_stream.h:515
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the request message size from the client.
Definition: sync_stream.h:749
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:763
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:719
Events are popped out by calling grpc_completion_queue_pluck() API ONLY.
Definition: grpc_types.h:597
Definition: call.h:428
virtual ~ClientStreamingInterface()
Definition: sync_stream.h:36
Server-side interface for streaming writes of message of type W.
Definition: sync_stream.h:553
virtual bool NextMessageSize(uint32_t *sz)=0
Get an upper bound on the next message size available for reading on this stream. ...
ClientReader(ChannelInterface *channel, const RpcMethod &method, ClientContext *context, const W &request)
Block to create a stream and write the initial metadata and request out.
Definition: sync_stream.h:166
CompletionQueue * cq() const
Definition: call.h:668
int max_receive_message_size() const
Definition: call.h:670
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:588
Straightforward wrapping of the C call object.
Definition: call.h:647
virtual bool WritesDone()=0
Half close writing from the client.
Codegen interface for grpc::Channel.
Definition: channel_interface.h:49
virtual bool Write(const W &msg, WriteOptions options)=0
Block to write msg to the stream with WriteOptions options.
virtual void SendInitialMetadata()=0
Block to send initial metadata to client.
The completion queue will have an associated pollset and there is no restriction on the type of file ...
Definition: grpc_types.h:577
Primary implementaiton of CallOpSetInterface.
Definition: call.h:591
Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:343
A ServerContext allows the person implementing a service handler to:
Definition: server_context.h:95
ServerSplitStreamer(Call *call, ServerContext *ctx)
Definition: sync_stream.h:802
Per-message write options.
Definition: call.h:81
void SendInitialMetadata() override
Block to send initial metadata to client.
Definition: sync_stream.h:746
ClientReaderWriter(ChannelInterface *channel, const RpcMethod &method, ClientContext *context)
Block to create a stream and write the initial metadata and request out.
Definition: sync_stream.h:396
bool NextMessageSize(uint32_t *sz) override
Get an upper bound on the next message size available for reading on this stream. ...
Definition: sync_stream.h:534
virtual void WaitForInitialMetadata()=0
Block to wait for initial metadata from server.
virtual bool WritesDone()=0
Half close writing from the client.
bool Write(const W &msg)
Block to write msg to the stream with default write options.
Definition: sync_stream.h:123
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs, where the outgoing message stream coming from the server has messages of type W.
Definition: completion_queue.h:55
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:86
ServerUnaryStreamer(Call *call, ServerContext *ctx)
Definition: sync_stream.h:739
bool WritesDone() override
Half close writing from the client.
Definition: sync_stream.h:474
Descriptor of an RPC method.
Definition: rpc_method.h:29
Status Finish() override
See the ClientStreamingInterface.Finish method for semantics.
Definition: sync_stream.h:486
virtual Status Finish()=0
Block waiting until the stream finishes and a final status of the call is available.
void WaitForInitialMetadata() override
Block waiting to read initial metadata from the server.
Definition: sync_stream.h:418
ServerReaderWriter(Call *call, ServerContext *ctx)
Definition: sync_stream.h:700
Synchronous (blocking) server-side API for a bidirectional streaming call, where the incoming message...
Definition: sync_stream.h:698
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:663
An interface that can be fed a sequence of messages of type W.
Definition: sync_stream.h:104
Client-side interface for bi-directional streaming with client-to-server stream messages of type W an...
Definition: sync_stream.h:367
Did it work? If it didn't, why?
Definition: status.h:30
void WaitForInitialMetadata() override
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:192
virtual bool Read(R *msg)=0
Block to read a message and parse to msg.
Common interface for all synchronous client side streaming.
Definition: sync_stream.h:34
ServerWriter(Call *call, ServerContext *ctx)
Definition: sync_stream.h:562
Definition: call.h:203
bool Read(RequestType *request) override
Read a message of type R into msg.
Definition: sync_stream.h:826
void WriteLast(const W &msg, WriteOptions options)
Write msg and coalesce it with the writing of trailing metadata, using WriteOptions options...
Definition: sync_stream.h:139
void WaitForInitialMetadata()
See the ClientStreamingInterface.WaitForInitialMetadata method for semantics.
Definition: sync_stream.h:292
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: channel_interface.h:38
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
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: channel_interface.h:36
Definition: call.h:495
ClientWriter(ChannelInterface *channel, const RpcMethod &method, ClientContext *context, R *response)
Block to create a stream (i.e.
Definition: sync_stream.h:267
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
virtual ~WriterInterface()
Definition: sync_stream.h:106
Definition: call.h:374
bool Write(const W &msg, WriteOptions options) override
Block to write msg to the stream with WriteOptions options.
Definition: sync_stream.h:308