GRPC C++  1.0.0
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 
50 
54 
55 struct grpc_byte_buffer;
56 
57 namespace grpc {
58 
59 class ByteBuffer;
60 class Call;
61 class CallHook;
64 
65 inline void FillMetadataMap(
67  std::multimap<grpc::string_ref, grpc::string_ref>* metadata) {
68  for (size_t i = 0; i < arr->count; i++) {
69  // TODO(yangg) handle duplicates?
70  metadata->insert(std::pair<grpc::string_ref, grpc::string_ref>(
71  arr->metadata[i].key, grpc::string_ref(arr->metadata[i].value,
72  arr->metadata[i].value_length)));
73  }
74  g_core_codegen_interface->grpc_metadata_array_destroy(arr);
75  g_core_codegen_interface->grpc_metadata_array_init(arr);
76 }
77 
78 // TODO(yangg) if the map is changed before we send, the pointers will be a
79 // mess. Make sure it does not happen.
81  const std::multimap<grpc::string, grpc::string>& metadata) {
82  if (metadata.empty()) {
83  return nullptr;
84  }
85  grpc_metadata* metadata_array =
86  (grpc_metadata*)(g_core_codegen_interface->gpr_malloc(
87  metadata.size() * sizeof(grpc_metadata)));
88  size_t i = 0;
89  for (auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
90  metadata_array[i].key = iter->first.c_str();
91  metadata_array[i].value = iter->second.c_str();
92  metadata_array[i].value_length = iter->second.size();
93  }
94  return metadata_array;
95 }
96 
98 class WriteOptions {
99  public:
100  WriteOptions() : flags_(0) {}
101  WriteOptions(const WriteOptions& other) : flags_(other.flags_) {}
102 
104  inline void Clear() { flags_ = 0; }
105 
107  inline uint32_t flags() const { return flags_; }
108 
113  SetBit(GRPC_WRITE_NO_COMPRESS);
114  return *this;
115  }
116 
121  ClearBit(GRPC_WRITE_NO_COMPRESS);
122  return *this;
123  }
124 
129  inline bool get_no_compression() const {
130  return GetBit(GRPC_WRITE_NO_COMPRESS);
131  }
132 
138  SetBit(GRPC_WRITE_BUFFER_HINT);
139  return *this;
140  }
141 
147  ClearBit(GRPC_WRITE_BUFFER_HINT);
148  return *this;
149  }
150 
155  inline bool get_buffer_hint() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
156 
158  flags_ = rhs.flags_;
159  return *this;
160  }
161 
162  private:
163  void SetBit(const uint32_t mask) { flags_ |= mask; }
164 
165  void ClearBit(const uint32_t mask) { flags_ &= ~mask; }
166 
167  bool GetBit(const uint32_t mask) const { return (flags_ & mask) != 0; }
168 
169  uint32_t flags_;
170 };
171 
174 template <int I>
175 class CallNoOp {
176  protected:
177  void AddOp(grpc_op* ops, size_t* nops) {}
178  void FinishOp(bool* status, int max_message_size) {}
179 };
180 
182  public:
183  CallOpSendInitialMetadata() : send_(false) {
184  maybe_compression_level_.is_set = false;
185  }
186 
188  const std::multimap<grpc::string, grpc::string>& metadata,
189  uint32_t flags) {
190  maybe_compression_level_.is_set = false;
191  send_ = true;
192  flags_ = flags;
193  initial_metadata_count_ = metadata.size();
194  initial_metadata_ = FillMetadataArray(metadata);
195  }
196 
198  maybe_compression_level_.is_set = true;
199  maybe_compression_level_.level = level;
200  }
201 
202  protected:
203  void AddOp(grpc_op* ops, size_t* nops) {
204  if (!send_) return;
205  grpc_op* op = &ops[(*nops)++];
207  op->flags = flags_;
208  op->reserved = NULL;
209  op->data.send_initial_metadata.count = initial_metadata_count_;
210  op->data.send_initial_metadata.metadata = initial_metadata_;
211  op->data.send_initial_metadata.maybe_compression_level.is_set =
212  maybe_compression_level_.is_set;
213  op->data.send_initial_metadata.maybe_compression_level.level =
214  maybe_compression_level_.level;
215  }
216  void FinishOp(bool* status, int max_message_size) {
217  if (!send_) return;
218  g_core_codegen_interface->gpr_free(initial_metadata_);
219  send_ = false;
220  }
221 
222  bool send_;
223  uint32_t flags_;
226  struct {
227  bool is_set;
229  } maybe_compression_level_;
230 };
231 
233  public:
234  CallOpSendMessage() : send_buf_(nullptr), own_buf_(false) {}
235 
238  template <class M>
239  Status SendMessage(const M& message,
240  const WriteOptions& options) GRPC_MUST_USE_RESULT;
241 
242  template <class M>
243  Status SendMessage(const M& message) GRPC_MUST_USE_RESULT;
244 
245  protected:
246  void AddOp(grpc_op* ops, size_t* nops) {
247  if (send_buf_ == nullptr) return;
248  grpc_op* op = &ops[(*nops)++];
249  op->op = GRPC_OP_SEND_MESSAGE;
250  op->flags = write_options_.flags();
251  op->reserved = NULL;
252  op->data.send_message = send_buf_;
253  // Flags are per-message: clear them after use.
254  write_options_.Clear();
255  }
256  void FinishOp(bool* status, int max_message_size) {
257  if (own_buf_) g_core_codegen_interface->grpc_byte_buffer_destroy(send_buf_);
258  send_buf_ = nullptr;
259  }
260 
261  private:
262  grpc_byte_buffer* send_buf_;
263  WriteOptions write_options_;
264  bool own_buf_;
265 };
266 
267 template <class M>
269  const WriteOptions& options) {
270  write_options_ = options;
271  return SerializationTraits<M>::Serialize(message, &send_buf_, &own_buf_);
272 }
273 
274 template <class M>
276  return SendMessage(message, WriteOptions());
277 }
278 
279 template <class R>
281  public:
283  : got_message(false),
284  message_(nullptr),
285  allow_not_getting_message_(false) {}
286 
287  void RecvMessage(R* message) { message_ = message; }
288 
289  // Do not change status if no message is received.
290  void AllowNoMessage() { allow_not_getting_message_ = true; }
291 
293 
294  protected:
295  void AddOp(grpc_op* ops, size_t* nops) {
296  if (message_ == nullptr) return;
297  grpc_op* op = &ops[(*nops)++];
298  op->op = GRPC_OP_RECV_MESSAGE;
299  op->flags = 0;
300  op->reserved = NULL;
301  op->data.recv_message = &recv_buf_;
302  }
303 
304  void FinishOp(bool* status, int max_message_size) {
305  if (message_ == nullptr) return;
306  if (recv_buf_) {
307  if (*status) {
308  got_message = *status = SerializationTraits<R>::Deserialize(
309  recv_buf_, message_, max_message_size)
310  .ok();
311  } else {
312  got_message = false;
313  g_core_codegen_interface->grpc_byte_buffer_destroy(recv_buf_);
314  }
315  } else {
316  got_message = false;
317  if (!allow_not_getting_message_) {
318  *status = false;
319  }
320  }
321  message_ = nullptr;
322  }
323 
324  private:
325  R* message_;
326  grpc_byte_buffer* recv_buf_;
327  bool allow_not_getting_message_;
328 };
329 
330 namespace CallOpGenericRecvMessageHelper {
332  public:
333  virtual Status Deserialize(grpc_byte_buffer* buf, int max_message_size) = 0;
334  virtual ~DeserializeFunc() {}
335 };
336 
337 template <class R>
339  public:
340  DeserializeFuncType(R* message) : message_(message) {}
342  int max_message_size) GRPC_OVERRIDE {
343  return SerializationTraits<R>::Deserialize(buf, message_, max_message_size);
344  }
345 
347 
348  private:
349  R* message_; // Not a managed pointer because management is external to this
350 };
351 } // namespace CallOpGenericRecvMessageHelper
352 
354  public:
356  : got_message(false), allow_not_getting_message_(false) {}
357 
358  template <class R>
359  void RecvMessage(R* message) {
360  // Use an explicit base class pointer to avoid resolution error in the
361  // following unique_ptr::reset for some old implementations.
364  deserialize_.reset(func);
365  }
366 
367  // Do not change status if no message is received.
368  void AllowNoMessage() { allow_not_getting_message_ = true; }
369 
371 
372  protected:
373  void AddOp(grpc_op* ops, size_t* nops) {
374  if (!deserialize_) return;
375  grpc_op* op = &ops[(*nops)++];
376  op->op = GRPC_OP_RECV_MESSAGE;
377  op->flags = 0;
378  op->reserved = NULL;
379  op->data.recv_message = &recv_buf_;
380  }
381 
382  void FinishOp(bool* status, int max_message_size) {
383  if (!deserialize_) return;
384  if (recv_buf_) {
385  if (*status) {
386  got_message = true;
387  *status = deserialize_->Deserialize(recv_buf_, max_message_size).ok();
388  } else {
389  got_message = false;
390  g_core_codegen_interface->grpc_byte_buffer_destroy(recv_buf_);
391  }
392  } else {
393  got_message = false;
394  if (!allow_not_getting_message_) {
395  *status = false;
396  }
397  }
398  deserialize_.reset();
399  }
400 
401  private:
402  std::unique_ptr<CallOpGenericRecvMessageHelper::DeserializeFunc> deserialize_;
403  grpc_byte_buffer* recv_buf_;
404  bool allow_not_getting_message_;
405 };
406 
408  public:
409  CallOpClientSendClose() : send_(false) {}
410 
411  void ClientSendClose() { send_ = true; }
412 
413  protected:
414  void AddOp(grpc_op* ops, size_t* nops) {
415  if (!send_) return;
416  grpc_op* op = &ops[(*nops)++];
418  op->flags = 0;
419  op->reserved = NULL;
420  }
421  void FinishOp(bool* status, int max_message_size) { send_ = false; }
422 
423  private:
424  bool send_;
425 };
426 
428  public:
429  CallOpServerSendStatus() : send_status_available_(false) {}
430 
432  const std::multimap<grpc::string, grpc::string>& trailing_metadata,
433  const Status& status) {
434  trailing_metadata_count_ = trailing_metadata.size();
435  trailing_metadata_ = FillMetadataArray(trailing_metadata);
436  send_status_available_ = true;
437  send_status_code_ = static_cast<grpc_status_code>(status.error_code());
438  send_status_details_ = status.error_message();
439  }
440 
441  protected:
442  void AddOp(grpc_op* ops, size_t* nops) {
443  if (!send_status_available_) return;
444  grpc_op* op = &ops[(*nops)++];
446  op->data.send_status_from_server.trailing_metadata_count =
447  trailing_metadata_count_;
448  op->data.send_status_from_server.trailing_metadata = trailing_metadata_;
449  op->data.send_status_from_server.status = send_status_code_;
450  op->data.send_status_from_server.status_details =
451  send_status_details_.empty() ? nullptr : send_status_details_.c_str();
452  op->flags = 0;
453  op->reserved = NULL;
454  }
455 
456  void FinishOp(bool* status, int max_message_size) {
457  if (!send_status_available_) return;
458  g_core_codegen_interface->gpr_free(trailing_metadata_);
459  send_status_available_ = false;
460  }
461 
462  private:
463  bool send_status_available_;
464  grpc_status_code send_status_code_;
465  grpc::string send_status_details_;
466  size_t trailing_metadata_count_;
467  grpc_metadata* trailing_metadata_;
468 };
469 
471  public:
472  CallOpRecvInitialMetadata() : recv_initial_metadata_(nullptr) {}
473 
475  context->initial_metadata_received_ = true;
476  recv_initial_metadata_ = &context->recv_initial_metadata_;
477  }
478 
479  protected:
480  void AddOp(grpc_op* ops, size_t* nops) {
481  if (!recv_initial_metadata_) return;
482  memset(&recv_initial_metadata_arr_, 0, sizeof(recv_initial_metadata_arr_));
483  grpc_op* op = &ops[(*nops)++];
485  op->data.recv_initial_metadata = &recv_initial_metadata_arr_;
486  op->flags = 0;
487  op->reserved = NULL;
488  }
489  void FinishOp(bool* status, int max_message_size) {
490  if (recv_initial_metadata_ == nullptr) return;
491  FillMetadataMap(&recv_initial_metadata_arr_, recv_initial_metadata_);
492  recv_initial_metadata_ = nullptr;
493  }
494 
495  private:
496  std::multimap<grpc::string_ref, grpc::string_ref>* recv_initial_metadata_;
497  grpc_metadata_array recv_initial_metadata_arr_;
498 };
499 
501  public:
502  CallOpClientRecvStatus() : recv_status_(nullptr) {}
503 
504  void ClientRecvStatus(ClientContext* context, Status* status) {
505  recv_trailing_metadata_ = &context->trailing_metadata_;
506  recv_status_ = status;
507  }
508 
509  protected:
510  void AddOp(grpc_op* ops, size_t* nops) {
511  if (recv_status_ == nullptr) return;
512  memset(&recv_trailing_metadata_arr_, 0,
513  sizeof(recv_trailing_metadata_arr_));
514  status_details_ = nullptr;
515  status_details_capacity_ = 0;
516  grpc_op* op = &ops[(*nops)++];
518  op->data.recv_status_on_client.trailing_metadata =
519  &recv_trailing_metadata_arr_;
520  op->data.recv_status_on_client.status = &status_code_;
521  op->data.recv_status_on_client.status_details = &status_details_;
522  op->data.recv_status_on_client.status_details_capacity =
523  &status_details_capacity_;
524  op->flags = 0;
525  op->reserved = NULL;
526  }
527 
528  void FinishOp(bool* status, int max_message_size) {
529  if (recv_status_ == nullptr) return;
530  FillMetadataMap(&recv_trailing_metadata_arr_, recv_trailing_metadata_);
531  *recv_status_ = Status(
532  static_cast<StatusCode>(status_code_),
533  status_details_ ? grpc::string(status_details_) : grpc::string());
534  g_core_codegen_interface->gpr_free(status_details_);
535  recv_status_ = nullptr;
536  }
537 
538  private:
539  std::multimap<grpc::string_ref, grpc::string_ref>* recv_trailing_metadata_;
540  Status* recv_status_;
541  grpc_metadata_array recv_trailing_metadata_arr_;
542  grpc_status_code status_code_;
543  char* status_details_;
544  size_t status_details_capacity_;
545 };
546 
556  : public std::enable_shared_from_this<CallOpSetCollectionInterface> {};
557 
564  public:
565  CallOpSetInterface() : max_message_size_(0) {}
568  virtual void FillOps(grpc_op* ops, size_t* nops) = 0;
569 
570  void set_max_message_size(int max_message_size) {
571  max_message_size_ = max_message_size;
572  }
573 
575  void SetCollection(std::shared_ptr<CallOpSetCollectionInterface> collection) {
576  collection_ = collection;
577  }
578 
579  protected:
581  std::shared_ptr<CallOpSetCollectionInterface> collection_;
582 };
583 
590 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
591  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
592  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
594  public Op1,
595  public Op2,
596  public Op3,
597  public Op4,
598  public Op5,
599  public Op6 {
600  public:
601  CallOpSet() : return_tag_(this) {}
602  void FillOps(grpc_op* ops, size_t* nops) GRPC_OVERRIDE {
603  this->Op1::AddOp(ops, nops);
604  this->Op2::AddOp(ops, nops);
605  this->Op3::AddOp(ops, nops);
606  this->Op4::AddOp(ops, nops);
607  this->Op5::AddOp(ops, nops);
608  this->Op6::AddOp(ops, nops);
609  }
610 
611  bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE {
612  this->Op1::FinishOp(status, max_message_size_);
613  this->Op2::FinishOp(status, max_message_size_);
614  this->Op3::FinishOp(status, max_message_size_);
615  this->Op4::FinishOp(status, max_message_size_);
616  this->Op5::FinishOp(status, max_message_size_);
617  this->Op6::FinishOp(status, max_message_size_);
618  *tag = return_tag_;
619  collection_.reset(); // drop the ref at this point
620  return true;
621  }
622 
623  void set_output_tag(void* return_tag) { return_tag_ = return_tag; }
624 
625  private:
626  void* return_tag_;
627 };
628 
633 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
634  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
635  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
636 class SneakyCallOpSet : public CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> {
637  public:
638  bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE {
640  return Base::FinalizeResult(tag, status) && false;
641  }
642 };
643 
644 // Straightforward wrapping of the C call object
646  public:
647  /* call is owned by the caller */
648  Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq)
649  : call_hook_(call_hook), cq_(cq), call_(call), max_message_size_(-1) {}
650 
651  Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq,
652  int max_message_size)
653  : call_hook_(call_hook),
654  cq_(cq),
655  call_(call),
656  max_message_size_(max_message_size) {}
657 
659  if (max_message_size_ > 0) {
660  ops->set_max_message_size(max_message_size_);
661  }
662  call_hook_->PerformOpsOnCall(ops, this);
663  }
664 
665  grpc_call* call() { return call_; }
666  CompletionQueue* cq() { return cq_; }
667 
668  int max_message_size() { return max_message_size_; }
669 
670  private:
671  CallHook* call_hook_;
672  CompletionQueue* cq_;
673  grpc_call* call_;
674  int max_message_size_;
675 };
676 
677 } // namespace grpc
678 
679 #endif // GRPCXX_IMPL_CODEGEN_CALL_H
void ServerSendStatus(const std::multimap< grpc::string, grpc::string > &trailing_metadata, const Status &status)
Definition: call.h:431
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:62
CallOpRecvInitialMetadata()
Definition: call.h:472
grpc_op_type op
Operation type, as defined by grpc_op_type.
Definition: grpc_types.h:334
void RecvMessage(R *message)
Definition: call.h:359
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:146
Default argument for CallOpSet.
Definition: call.h:175
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:414
CallOpServerSendStatus()
Definition: call.h:429
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:137
grpc_metadata_array * recv_initial_metadata
ownership of the array is with the caller, but ownership of the elements stays with the call object (...
Definition: grpc_types.h:366
grpc::string error_message() const
Return the instance&#39;s error message.
Definition: status.h:64
CallOpSendMessage()
Definition: call.h:234
std::string string
Definition: config.h:118
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:373
CompletionQueue * cq()
Definition: call.h:666
void SetCollection(std::shared_ptr< CallOpSetCollectionInterface > collection)
Mark this as belonging to a collection if needed.
Definition: call.h:575
void FinishOp(bool *status, int max_message_size)
Definition: call.h:382
virtual void grpc_metadata_array_destroy(grpc_metadata_array *array)=0
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call.h:120
int max_message_size_
Definition: call.h:580
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:300
bool FinalizeResult(void **tag, bool *status) GRPC_OVERRIDE
Definition: call.h:638
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:563
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:306
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:216
void AllowNoMessage()
Definition: call.h:290
Definition: call.h:500
void FinishOp(bool *status, int max_message_size)
Definition: call.h:421
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:295
bool FinalizeResult(void **tag, bool *status) GRPC_OVERRIDE
Definition: call.h:611
void Clear()
Clear all flags.
Definition: call.h:104
grpc_compression_level level
Definition: call.h:228
#define GRPC_MUST_USE_RESULT
Definition: port_platform.h:438
#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:213
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
Definition: call.h:648
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:294
void FinishOp(bool *status, int max_message_size)
Definition: call.h:256
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:442
An abstract collection of CallOpSet&#39;s, to be used whenever CallOpSet objects must be thought of as a ...
Definition: call.h:555
WriteOptions()
Definition: call.h:100
Definition: byte_buffer.h:49
grpc_byte_buffer ** recv_message
ownership of the byte buffer is moved to the caller; the caller must call grpc_byte_buffer_destroy on...
Definition: grpc_types.h:370
Definition: call.h:427
void FillOps(grpc_op *ops, size_t *nops) GRPC_OVERRIDE
Fills in grpc_op, starting from ops[*nops] and moving upwards.
Definition: call.h:602
Definition: grpc_types.h:269
grpc_compression_level
Compression levels allow a party with knowledge of its peer&#39;s accepted encodings to request compressi...
Definition: compression_types.h:84
uint32_t flags() const
Returns raw flags bitset.
Definition: call.h:107
grpc_metadata * FillMetadataArray(const std::multimap< grpc::string, grpc::string > &metadata)
Definition: call.h:80
grpc_call * call()
Definition: call.h:665
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:203
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call.h:112
Definition: client_context.h:154
WriteOptions & operator=(const WriteOptions &rhs)
Definition: call.h:157
void FinishOp(bool *status, int max_message_size)
Definition: call.h:528
virtual void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)=0
grpc_metadata * metadata
Definition: grpc_types.h:272
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:64
struct grpc_op::@11::@13 send_initial_metadata
struct grpc_op::@11::@15 recv_status_on_client
void SendInitialMetadata(const std::multimap< grpc::string, grpc::string > &metadata, uint32_t flags)
Definition: call.h:187
Definition: call.h:232
bool send_
Definition: call.h:222
CallOpClientRecvStatus()
Definition: call.h:502
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call.h:129
const char * key
Definition: grpc_types.h:232
Status Deserialize(grpc_byte_buffer *buf, int max_message_size) GRPC_OVERRIDE
Definition: call.h:341
CallOpSet()
Definition: call.h:601
void FinishOp(bool *status, int max_message_size)
Definition: call.h:456
Definition: call.h:407
bool is_set
Definition: call.h:227
CallOpSendInitialMetadata()
Definition: call.h:183
void AllowNoMessage()
Definition: call.h:368
void FillMetadataMap(grpc_metadata_array *arr, std::multimap< grpc::string_ref, grpc::string_ref > *metadata)
Definition: call.h:65
A single metadata element.
Definition: grpc_types.h:231
struct grpc_op::@11::@14 send_status_from_server
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:510
Definition: call.h:645
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:332
Definition: alarm.h:48
Receive initial metadata: one and only one MUST be made on the client, must not be made on the server...
Definition: grpc_types.h:311
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:177
void FinishOp(bool *status, int max_message_size)
Definition: call.h:489
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:62
CallOpSetInterface()
Definition: call.h:565
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:290
WriteOptions(const WriteOptions &other)
Definition: call.h:101
Primary implementaiton of CallOpSetInterface.
Definition: call.h:593
void ClientSendClose()
Definition: call.h:411
Definition: call.h:280
int max_message_size()
Definition: call.h:668
Per-message write options.
Definition: call.h:98
CallOpClientSendClose()
Definition: call.h:409
~DeserializeFuncType() GRPC_OVERRIDE
Definition: call.h:346
std::shared_ptr< CallOpSetCollectionInterface > collection_
Definition: call.h:581
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:155
CallOpRecvMessage()
Definition: call.h:282
StatusCode error_code() const
Return the instance&#39;s error code.
Definition: status.h:62
A thin wrapper around grpc_completion_queue (see / src/core/surface/completion_queue.h).
Definition: completion_queue.h:97
Status SendMessage(const M &message, const WriteOptions &options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:268
#define GRPC_FINAL
Definition: config.h:72
size_t count
Definition: grpc_types.h:270
void FinishOp(bool *status, int max_message_size)
Definition: call.h:178
This class is a non owning reference to a string.
Definition: string_ref.h:56
bool got_message
Definition: call.h:292
union grpc_op::@11 data
const char * value
Definition: grpc_types.h:233
void ClientRecvStatus(ClientContext *context, Status *status)
Definition: call.h:504
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:50
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:658
void FinishOp(bool *status, int max_message_size)
Definition: call.h:304
void set_max_message_size(int max_message_size)
Definition: call.h:570
DeserializeFuncType(R *message)
Definition: call.h:340
Did it work? If it didn&#39;t, why?
Definition: status.h:45
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_message_size)
Definition: call.h:651
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:321
Definition: call.h:181
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:480
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:336
virtual void grpc_metadata_array_init(grpc_metadata_array *array)=0
void RecvMessage(R *message)
Definition: call.h:287
void * reserved
Reserved for future usage.
Definition: grpc_types.h:338
CallOpGenericRecvMessage()
Definition: call.h:355
virtual void gpr_free(void *p)=0
void set_compression_level(grpc_compression_level level)
Definition: call.h:197
grpc_byte_buffer * send_message
Definition: grpc_types.h:354
bool got_message
Definition: call.h:370
A CallOpSet that does not post completions to the completion queue.
Definition: call.h:636
uint32_t flags_
Definition: call.h:223
void set_output_tag(void *return_tag)
Definition: call.h:623
size_t initial_metadata_count_
Definition: call.h:224
Receive a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:315
size_t value_length
Definition: grpc_types.h:234
Channel and Server implement this to allow them to hook performing ops.
Definition: call_hook.h:43
#define GRPC_OVERRIDE
Definition: config.h:78
void RecvInitialMetadata(ClientContext *context)
Definition: call.h:474
Definition: call.h:470
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:246
virtual ~DeserializeFunc()
Definition: call.h:334
struct grpc_metadata grpc_metadata
A single metadata element.
grpc_metadata * initial_metadata_
Definition: call.h:225
void FinishOp(bool *status, int max_message_size)
Definition: call.h:216
Definition: call.h:353
virtual void * gpr_malloc(size_t size)=0