GRPC C++  1.3.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
call.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_CALL_H
35 #define GRPCXX_IMPL_CODEGEN_CALL_H
36 
37 #include <cstring>
38 #include <functional>
39 #include <map>
40 #include <memory>
41 
52 
55 
56 struct grpc_byte_buffer;
57 
58 namespace grpc {
59 
60 class ByteBuffer;
61 class Call;
62 class CallHook;
65 
66 const char kBinaryErrorDetailsKey[] = "grpc-status-details-bin";
67 
68 // TODO(yangg) if the map is changed before we send, the pointers will be a
69 // mess. Make sure it does not happen.
71  const std::multimap<grpc::string, grpc::string>& metadata,
72  size_t* metadata_count, const grpc::string& optional_error_details) {
73  *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1);
74  if (*metadata_count == 0) {
75  return nullptr;
76  }
77  grpc_metadata* metadata_array =
79  (*metadata_count) * sizeof(grpc_metadata)));
80  size_t i = 0;
81  for (auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
82  metadata_array[i].key = SliceReferencingString(iter->first);
83  metadata_array[i].value = SliceReferencingString(iter->second);
84  }
85  if (!optional_error_details.empty()) {
86  metadata_array[i].key =
89  metadata_array[i].value = SliceReferencingString(optional_error_details);
90  }
91  return metadata_array;
92 }
93 
95 class WriteOptions {
96  public:
97  WriteOptions() : flags_(0), last_message_(false) {}
98  WriteOptions(const WriteOptions& other)
99  : flags_(other.flags_), last_message_(other.last_message_) {}
100 
102  inline void Clear() { flags_ = 0; }
103 
105  inline uint32_t flags() const { return flags_; }
106 
111  SetBit(GRPC_WRITE_NO_COMPRESS);
112  return *this;
113  }
114 
119  ClearBit(GRPC_WRITE_NO_COMPRESS);
120  return *this;
121  }
122 
127  inline bool get_no_compression() const {
128  return GetBit(GRPC_WRITE_NO_COMPRESS);
129  }
130 
136  SetBit(GRPC_WRITE_BUFFER_HINT);
137  return *this;
138  }
139 
145  ClearBit(GRPC_WRITE_BUFFER_HINT);
146  return *this;
147  }
148 
153  inline bool get_buffer_hint() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
154 
158  SetBit(GRPC_WRITE_BUFFER_HINT);
159  return *this;
160  }
161 
163  ClearBit(GRPC_WRITE_BUFFER_HINT);
164  return *this;
165  }
166 
167  inline bool is_corked() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
168 
175  last_message_ = true;
176  return *this;
177  }
178 
182  last_message_ = false;
183  return *this;
184  }
185 
190  bool is_last_message() const { return last_message_; }
191 
193  flags_ = rhs.flags_;
194  return *this;
195  }
196 
197  private:
198  void SetBit(const uint32_t mask) { flags_ |= mask; }
199 
200  void ClearBit(const uint32_t mask) { flags_ &= ~mask; }
201 
202  bool GetBit(const uint32_t mask) const { return (flags_ & mask) != 0; }
203 
204  uint32_t flags_;
205  bool last_message_;
206 };
207 
210 template <int I>
211 class CallNoOp {
212  protected:
213  void AddOp(grpc_op* ops, size_t* nops) {}
214  void FinishOp(bool* status) {}
215 };
216 
218  public:
220  maybe_compression_level_.is_set = false;
221  }
222 
224  const std::multimap<grpc::string, grpc::string>& metadata,
225  uint32_t flags) {
226  maybe_compression_level_.is_set = false;
227  send_ = true;
228  flags_ = flags;
231  }
232 
234  maybe_compression_level_.is_set = true;
236  }
237 
238  protected:
239  void AddOp(grpc_op* ops, size_t* nops) {
240  if (!send_) return;
241  grpc_op* op = &ops[(*nops)++];
243  op->flags = flags_;
244  op->reserved = NULL;
247  op->data.send_initial_metadata.maybe_compression_level.is_set =
249  op->data.send_initial_metadata.maybe_compression_level.level =
251  }
252  void FinishOp(bool* status) {
253  if (!send_) return;
255  send_ = false;
256  }
257 
258  bool send_;
259  uint32_t flags_;
262  struct {
263  bool is_set;
266 };
267 
269  public:
270  CallOpSendMessage() : send_buf_(nullptr), own_buf_(false) {}
271 
274  template <class M>
275  Status SendMessage(const M& message,
277 
278  template <class M>
279  Status SendMessage(const M& message) GRPC_MUST_USE_RESULT;
280 
281  protected:
282  void AddOp(grpc_op* ops, size_t* nops) {
283  if (send_buf_ == nullptr) return;
284  grpc_op* op = &ops[(*nops)++];
285  op->op = GRPC_OP_SEND_MESSAGE;
286  op->flags = write_options_.flags();
287  op->reserved = NULL;
288  op->data.send_message.send_message = send_buf_;
289  // Flags are per-message: clear them after use.
290  write_options_.Clear();
291  }
292  void FinishOp(bool* status) {
293  if (own_buf_) g_core_codegen_interface->grpc_byte_buffer_destroy(send_buf_);
294  send_buf_ = nullptr;
295  }
296 
297  private:
298  grpc_byte_buffer* send_buf_;
299  WriteOptions write_options_;
300  bool own_buf_;
301 };
302 
303 template <class M>
305  write_options_ = options;
306  return SerializationTraits<M>::Serialize(message, &send_buf_, &own_buf_);
307 }
308 
309 template <class M>
311  return SendMessage(message, WriteOptions());
312 }
313 
314 template <class R>
316  public:
318  : got_message(false),
319  message_(nullptr),
320  allow_not_getting_message_(false) {}
321 
322  void RecvMessage(R* message) { message_ = message; }
323 
324  // Do not change status if no message is received.
325  void AllowNoMessage() { allow_not_getting_message_ = true; }
326 
328 
329  protected:
330  void AddOp(grpc_op* ops, size_t* nops) {
331  if (message_ == nullptr) return;
332  grpc_op* op = &ops[(*nops)++];
333  op->op = GRPC_OP_RECV_MESSAGE;
334  op->flags = 0;
335  op->reserved = NULL;
336  op->data.recv_message.recv_message = &recv_buf_;
337  }
338 
339  void FinishOp(bool* status) {
340  if (message_ == nullptr) return;
341  if (recv_buf_) {
342  if (*status) {
343  got_message = *status =
344  SerializationTraits<R>::Deserialize(recv_buf_, message_).ok();
345  } else {
346  got_message = false;
348  }
349  } else {
350  got_message = false;
351  if (!allow_not_getting_message_) {
352  *status = false;
353  }
354  }
355  message_ = nullptr;
356  }
357 
358  private:
359  R* message_;
360  grpc_byte_buffer* recv_buf_;
361  bool allow_not_getting_message_;
362 };
363 
364 namespace CallOpGenericRecvMessageHelper {
366  public:
367  virtual Status Deserialize(grpc_byte_buffer* buf) = 0;
368  virtual ~DeserializeFunc() {}
369 };
370 
371 template <class R>
372 class DeserializeFuncType final : public DeserializeFunc {
373  public:
374  DeserializeFuncType(R* message) : message_(message) {}
376  return SerializationTraits<R>::Deserialize(buf, message_);
377  }
378 
379  ~DeserializeFuncType() override {}
380 
381  private:
382  R* message_; // Not a managed pointer because management is external to this
383 };
384 } // namespace CallOpGenericRecvMessageHelper
385 
387  public:
389  : got_message(false), allow_not_getting_message_(false) {}
390 
391  template <class R>
392  void RecvMessage(R* message) {
393  // Use an explicit base class pointer to avoid resolution error in the
394  // following unique_ptr::reset for some old implementations.
397  deserialize_.reset(func);
398  }
399 
400  // Do not change status if no message is received.
401  void AllowNoMessage() { allow_not_getting_message_ = true; }
402 
404 
405  protected:
406  void AddOp(grpc_op* ops, size_t* nops) {
407  if (!deserialize_) return;
408  grpc_op* op = &ops[(*nops)++];
409  op->op = GRPC_OP_RECV_MESSAGE;
410  op->flags = 0;
411  op->reserved = NULL;
412  op->data.recv_message.recv_message = &recv_buf_;
413  }
414 
415  void FinishOp(bool* status) {
416  if (!deserialize_) return;
417  if (recv_buf_) {
418  if (*status) {
419  got_message = true;
420  *status = deserialize_->Deserialize(recv_buf_).ok();
421  } else {
422  got_message = false;
424  }
425  } else {
426  got_message = false;
427  if (!allow_not_getting_message_) {
428  *status = false;
429  }
430  }
431  deserialize_.reset();
432  }
433 
434  private:
435  std::unique_ptr<CallOpGenericRecvMessageHelper::DeserializeFunc> deserialize_;
436  grpc_byte_buffer* recv_buf_;
437  bool allow_not_getting_message_;
438 };
439 
441  public:
442  CallOpClientSendClose() : send_(false) {}
443 
444  void ClientSendClose() { send_ = true; }
445 
446  protected:
447  void AddOp(grpc_op* ops, size_t* nops) {
448  if (!send_) return;
449  grpc_op* op = &ops[(*nops)++];
451  op->flags = 0;
452  op->reserved = NULL;
453  }
454  void FinishOp(bool* status) { send_ = false; }
455 
456  private:
457  bool send_;
458 };
459 
461  public:
462  CallOpServerSendStatus() : send_status_available_(false) {}
463 
465  const std::multimap<grpc::string, grpc::string>& trailing_metadata,
466  const Status& status) {
467  send_error_details_ = status.error_details();
468  trailing_metadata_ = FillMetadataArray(
469  trailing_metadata, &trailing_metadata_count_, send_error_details_);
470  send_status_available_ = true;
471  send_status_code_ = static_cast<grpc_status_code>(GetCanonicalCode(status));
472  send_error_message_ = status.error_message();
473  }
474 
475  protected:
476  void AddOp(grpc_op* ops, size_t* nops) {
477  if (!send_status_available_) return;
478  grpc_op* op = &ops[(*nops)++];
480  op->data.send_status_from_server.trailing_metadata_count =
481  trailing_metadata_count_;
482  op->data.send_status_from_server.trailing_metadata = trailing_metadata_;
483  op->data.send_status_from_server.status = send_status_code_;
484  error_message_slice_ = SliceReferencingString(send_error_message_);
485  op->data.send_status_from_server.status_details =
486  send_error_message_.empty() ? nullptr : &error_message_slice_;
487  op->flags = 0;
488  op->reserved = NULL;
489  }
490 
491  void FinishOp(bool* status) {
492  if (!send_status_available_) return;
493  g_core_codegen_interface->gpr_free(trailing_metadata_);
494  send_status_available_ = false;
495  }
496 
497  private:
498  bool send_status_available_;
499  grpc_status_code send_status_code_;
500  grpc::string send_error_details_;
501  grpc::string send_error_message_;
502  size_t trailing_metadata_count_;
503  grpc_metadata* trailing_metadata_;
504  grpc_slice error_message_slice_;
505 };
506 
508  public:
509  CallOpRecvInitialMetadata() : metadata_map_(nullptr) {}
510 
512  context->initial_metadata_received_ = true;
513  metadata_map_ = &context->recv_initial_metadata_;
514  }
515 
516  protected:
517  void AddOp(grpc_op* ops, size_t* nops) {
518  if (metadata_map_ == nullptr) return;
519  grpc_op* op = &ops[(*nops)++];
521  op->data.recv_initial_metadata.recv_initial_metadata = metadata_map_->arr();
522  op->flags = 0;
523  op->reserved = NULL;
524  }
525 
526  void FinishOp(bool* status) {
527  if (metadata_map_ == nullptr) return;
528  metadata_map_->FillMap();
529  metadata_map_ = nullptr;
530  }
531 
532  private:
533  MetadataMap* metadata_map_;
534 };
535 
537  public:
538  CallOpClientRecvStatus() : recv_status_(nullptr) {}
539 
540  void ClientRecvStatus(ClientContext* context, Status* status) {
541  metadata_map_ = &context->trailing_metadata_;
542  recv_status_ = status;
543  error_message_ = g_core_codegen_interface->grpc_empty_slice();
544  }
545 
546  protected:
547  void AddOp(grpc_op* ops, size_t* nops) {
548  if (recv_status_ == nullptr) return;
549  grpc_op* op = &ops[(*nops)++];
551  op->data.recv_status_on_client.trailing_metadata = metadata_map_->arr();
552  op->data.recv_status_on_client.status = &status_code_;
553  op->data.recv_status_on_client.status_details = &error_message_;
554  op->flags = 0;
555  op->reserved = NULL;
556  }
557 
558  void FinishOp(bool* status) {
559  if (recv_status_ == nullptr) return;
560  metadata_map_->FillMap();
561  grpc::string binary_error_details;
562  auto iter = metadata_map_->map()->find(kBinaryErrorDetailsKey);
563  if (iter != metadata_map_->map()->end()) {
564  binary_error_details =
565  grpc::string(iter->second.begin(), iter->second.length());
566  }
567  *recv_status_ = Status(static_cast<StatusCode>(status_code_),
568  grpc::string(GRPC_SLICE_START_PTR(error_message_),
569  GRPC_SLICE_END_PTR(error_message_)),
570  binary_error_details);
572  recv_status_ = nullptr;
573  }
574 
575  private:
576  MetadataMap* metadata_map_;
577  Status* recv_status_;
578  grpc_status_code status_code_;
579  grpc_slice error_message_;
580 };
581 
591  : public std::enable_shared_from_this<CallOpSetCollectionInterface> {};
592 
599  public:
603  virtual void FillOps(grpc_op* ops, size_t* nops) = 0;
604 
606  void SetCollection(std::shared_ptr<CallOpSetCollectionInterface> collection) {
607  collection_ = collection;
608  }
609 
610  protected:
611  std::shared_ptr<CallOpSetCollectionInterface> collection_;
612 };
613 
620 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
621  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
622  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
624  public Op1,
625  public Op2,
626  public Op3,
627  public Op4,
628  public Op5,
629  public Op6 {
630  public:
631  CallOpSet() : return_tag_(this) {}
632  void FillOps(grpc_op* ops, size_t* nops) override {
633  this->Op1::AddOp(ops, nops);
634  this->Op2::AddOp(ops, nops);
635  this->Op3::AddOp(ops, nops);
636  this->Op4::AddOp(ops, nops);
637  this->Op5::AddOp(ops, nops);
638  this->Op6::AddOp(ops, nops);
639  }
640 
641  bool FinalizeResult(void** tag, bool* status) override {
642  this->Op1::FinishOp(status);
643  this->Op2::FinishOp(status);
644  this->Op3::FinishOp(status);
645  this->Op4::FinishOp(status);
646  this->Op5::FinishOp(status);
647  this->Op6::FinishOp(status);
648  *tag = return_tag_;
649  collection_.reset(); // drop the ref at this point
650  return true;
651  }
652 
653  void set_output_tag(void* return_tag) { return_tag_ = return_tag; }
654 
655  private:
656  void* return_tag_;
657 };
658 
663 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
664  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
665  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
666 class SneakyCallOpSet : public CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> {
667  public:
668  bool FinalizeResult(void** tag, bool* status) override {
670  return Base::FinalizeResult(tag, status) && false;
671  }
672 };
673 
674 // Straightforward wrapping of the C call object
675 class Call final {
676  public:
677  /* call is owned by the caller */
679  : call_hook_(call_hook),
680  cq_(cq),
681  call_(call),
682  max_receive_message_size_(-1) {}
683 
686  : call_hook_(call_hook),
687  cq_(cq),
688  call_(call),
689  max_receive_message_size_(max_receive_message_size) {}
690 
692  call_hook_->PerformOpsOnCall(ops, this);
693  }
694 
695  grpc_call* call() const { return call_; }
696  CompletionQueue* cq() const { return cq_; }
697 
698  int max_receive_message_size() const { return max_receive_message_size_; }
699 
700  private:
701  CallHook* call_hook_;
702  CompletionQueue* cq_;
703  grpc_call* call_;
704  int max_receive_message_size_;
705 };
706 
707 } // namespace grpc
708 
709 #endif // GRPCXX_IMPL_CODEGEN_CALL_H
void ServerSendStatus(const std::multimap< grpc::string, grpc::string > &trailing_metadata, const Status &status)
Definition: call.h:464
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:85
CallOpRecvInitialMetadata()
Definition: call.h:509
grpc_op_type op
Operation type, as defined by grpc_op_type.
Definition: grpc_types.h:469
void RecvMessage(R *message)
Definition: call.h:392
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_receive_message_size)
Definition: call.h:684
bool is_corked() const
Definition: call.h:167
An interface allowing implementors to process and filter event tags.
Definition: completion_queue_tag.h:40
WriteOptions & clear_buffer_hint()
Clears flag indicating that the write may be buffered and need not go out on the wire immediately...
Definition: call.h:144
Default argument for CallOpSet.
Definition: call.h:211
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:447
CallOpServerSendStatus()
Definition: call.h:462
void FinishOp(bool *status)
Definition: call.h:214
grpc_status_code
Definition: status.h:41
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:135
grpc_metadata_array * recv_initial_metadata
Definition: grpc_types.h:507
grpc::string error_message() const
Return the instance's error message.
Definition: status.h:70
CallOpSendMessage()
Definition: call.h:270
std::string string
Definition: config.h:50
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:406
void SetCollection(std::shared_ptr< CallOpSetCollectionInterface > collection)
Mark this as belonging to a collection if needed.
Definition: call.h:606
union grpc_op::@12 data
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call.h:118
StatusCode GetCanonicalCode(const Status &status)
Definition: status_helper.h:41
Send a close from the client: one and only one instance MUST be sent from the client, unless the call was cancelled - in which case this can be skipped.
Definition: grpc_types.h:433
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:598
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:439
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:174
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:338
grpc_metadata_array * arr()
Definition: metadata_map.h:62
void AllowNoMessage()
Definition: call.h:325
grpc_slice key
Definition: grpc_types.h:367
void FinishOp(bool *status)
Definition: call.h:415
Definition: call.h:536
grpc_slice value
Definition: grpc_types.h:368
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:330
void Clear()
Clear all flags.
Definition: call.h:102
grpc_compression_level level
Definition: call.h:264
virtual grpc_slice grpc_empty_slice()=0
#define GRPC_MUST_USE_RESULT
Definition: port_platform.h:384
Definition: slice.h:90
#define GRPC_WRITE_BUFFER_HINT
Hint that the write may be buffered and need not go out on the wire immediately.
Definition: grpc_types.h:335
const char kBinaryErrorDetailsKey[]
Definition: call.h:66
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
Definition: call.h:678
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:427
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:476
An abstract collection of CallOpSet's, to be used whenever CallOpSet objects must be thought of as a ...
Definition: call.h:590
WriteOptions & clear_last_messsage()
Clears flag indicating that this is the last message in a stream, disabling coalescing.
Definition: call.h:181
Status Deserialize(grpc_byte_buffer *buf) override
Definition: call.h:375
Definition: metadata_map.h:41
WriteOptions()
Definition: call.h:97
bool FinalizeResult(void **tag, bool *status) override
Definition: call.h:668
struct grpc_op::@12::@19 recv_status_on_client
Definition: grpc_types.h:55
grpc_slice SliceReferencingString(const grpc::string &str)
Definition: slice.h:53
Definition: call.h:460
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:84
uint32_t flags() const
Returns raw flags bitset.
Definition: call.h:105
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:126
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:239
void FillMap()
Definition: metadata_map.h:49
WriteOptions & clear_corked()
Definition: call.h:162
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call.h:110
#define GRPC_SLICE_END_PTR(slice)
Definition: slice.h:135
Definition: client_context.h:154
WriteOptions & operator=(const WriteOptions &rhs)
Definition: call.h:192
void FillOps(grpc_op *ops, size_t *nops) override
Fills in grpc_op, starting from ops[*nops] and moving upwards.
Definition: call.h:632
virtual void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)=0
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:64
void SendInitialMetadata(const std::multimap< grpc::string, grpc::string > &metadata, uint32_t flags)
Definition: call.h:223
Definition: call.h:268
bool FinalizeResult(void **tag, bool *status) override
Definition: call.h:641
void FinishOp(bool *status)
Definition: call.h:491
bool send_
Definition: call.h:258
CallOpClientRecvStatus()
Definition: call.h:538
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call.h:127
struct grpc_byte_buffer * send_message
Definition: grpc_types.h:490
void FinishOp(bool *status)
Definition: call.h:454
CallOpSet()
Definition: call.h:631
Definition: call.h:440
Status SendMessage(const M &message, WriteOptions options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:304
bool is_set
Definition: call.h:263
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:513
CallOpSendInitialMetadata()
Definition: call.h:219
void AllowNoMessage()
Definition: call.h:401
CompletionQueue * cq() const
Definition: call.h:696
int max_receive_message_size() const
Definition: call.h:698
A single metadata element.
Definition: grpc_types.h:364
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:547
Definition: call.h:675
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:467
virtual grpc_slice grpc_slice_from_static_buffer(const void *buffer, size_t length)=0
Receive initial metadata: one and only one MUST be made on the client, must not be made on the server...
Definition: grpc_types.h:444
std::multimap< grpc::string_ref, grpc::string_ref > * map()
Definition: metadata_map.h:58
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:213
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:63
CallOpSetInterface()
Definition: call.h:600
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:423
WriteOptions(const WriteOptions &other)
Definition: call.h:98
Primary implementaiton of CallOpSetInterface.
Definition: call.h:623
struct grpc_op::@12::@14 send_initial_metadata
virtual Status Deserialize(grpc_byte_buffer *buf)=0
void ClientSendClose()
Definition: call.h:444
Definition: call.h:315
Per-message write options.
Definition: call.h:95
CallOpClientSendClose()
Definition: call.h:442
std::shared_ptr< CallOpSetCollectionInterface > collection_
Definition: call.h:611
bool get_buffer_hint() const
Get value for the flag indicating that the write may be buffered and need not go out on the wire imme...
Definition: call.h:153
void FinishOp(bool *status)
Definition: call.h:339
CallOpRecvMessage()
Definition: call.h:317
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:101
virtual void PerformOpsOnCall(CallOpSetInterface *ops, Call *call)=0
~DeserializeFuncType() override
Definition: call.h:379
void FinishOp(bool *status)
Definition: call.h:292
struct grpc_op::@12::@16 send_status_from_server
virtual void grpc_slice_unref(grpc_slice slice)=0
void FinishOp(bool *status)
Definition: call.h:526
bool got_message
Definition: call.h:327
grpc::string error_details() const
Return the (binary) error details.
Definition: status.h:73
void ClientRecvStatus(ClientContext *context, Status *status)
Definition: call.h:540
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:56
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:691
WriteOptions & set_corked()
corked bit: aliases set_buffer_hint currently, with the intent that set_buffer_hint will be removed i...
Definition: call.h:157
DeserializeFuncType(R *message)
Definition: call.h:374
Did it work? If it didn't, why?
Definition: status.h:45
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:454
Definition: call.h:217
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:517
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:471
grpc_metadata * FillMetadataArray(const std::multimap< grpc::string, grpc::string > &metadata, size_t *metadata_count, const grpc::string &optional_error_details)
Definition: call.h:70
struct grpc::CallOpSendInitialMetadata::@0 maybe_compression_level_
grpc_call * call() const
Definition: call.h:695
void RecvMessage(R *message)
Definition: call.h:322
void * reserved
Reserved for future usage.
Definition: grpc_types.h:473
CallOpGenericRecvMessage()
Definition: call.h:388
virtual void gpr_free(void *p)=0
void set_compression_level(grpc_compression_level level)
Definition: call.h:233
bool got_message
Definition: call.h:403
A CallOpSet that does not post completions to the completion queue.
Definition: call.h:666
virtual void FillOps(grpc_op *ops, size_t *nops)=0
Fills in grpc_op, starting from ops[*nops] and moving upwards.
void FinishOp(bool *status)
Definition: call.h:558
uint32_t flags_
Definition: call.h:259
void set_output_tag(void *return_tag)
Definition: call.h:653
size_t initial_metadata_count_
Definition: call.h:260
Receive a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:448
Channel and Server implement this to allow them to hook performing ops.
Definition: call_hook.h:43
void RecvInitialMetadata(ClientContext *context)
Definition: call.h:511
Definition: call.h:507
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:282
virtual ~DeserializeFunc()
Definition: call.h:368
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:190
grpc_metadata * initial_metadata_
Definition: call.h:261
Definition: call.h:386
virtual void * gpr_malloc(size_t size)=0
void FinishOp(bool *status)
Definition: call.h:252