GRPC C++  1.9.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 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_CALL_H
20 #define GRPCXX_IMPL_CODEGEN_CALL_H
21 
22 #include <assert.h>
23 #include <cstring>
24 #include <functional>
25 #include <map>
26 #include <memory>
27 
38 
39 #include <grpc/impl/codegen/atm.h>
42 
43 namespace grpc {
44 
45 class ByteBuffer;
48 
49 namespace internal {
50 class Call;
51 class CallHook;
52 
53 const char kBinaryErrorDetailsKey[] = "grpc-status-details-bin";
54 
55 // TODO(yangg) if the map is changed before we send, the pointers will be a
56 // mess. Make sure it does not happen.
58  const std::multimap<grpc::string, grpc::string>& metadata,
59  size_t* metadata_count, const grpc::string& optional_error_details) {
60  *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1);
61  if (*metadata_count == 0) {
62  return nullptr;
63  }
64  grpc_metadata* metadata_array =
66  (*metadata_count) * sizeof(grpc_metadata)));
67  size_t i = 0;
68  for (auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
69  metadata_array[i].key = SliceReferencingString(iter->first);
70  metadata_array[i].value = SliceReferencingString(iter->second);
71  }
72  if (!optional_error_details.empty()) {
73  metadata_array[i].key =
76  metadata_array[i].value = SliceReferencingString(optional_error_details);
77  }
78  return metadata_array;
79 }
80 } // namespace internal
81 
83 class WriteOptions {
84  public:
85  WriteOptions() : flags_(0), last_message_(false) {}
86  WriteOptions(const WriteOptions& other)
87  : flags_(other.flags_), last_message_(other.last_message_) {}
88 
90  inline void Clear() { flags_ = 0; }
91 
93  inline uint32_t flags() const { return flags_; }
94 
99  SetBit(GRPC_WRITE_NO_COMPRESS);
100  return *this;
101  }
102 
107  ClearBit(GRPC_WRITE_NO_COMPRESS);
108  return *this;
109  }
110 
115  inline bool get_no_compression() const {
116  return GetBit(GRPC_WRITE_NO_COMPRESS);
117  }
118 
124  SetBit(GRPC_WRITE_BUFFER_HINT);
125  return *this;
126  }
127 
133  ClearBit(GRPC_WRITE_BUFFER_HINT);
134  return *this;
135  }
136 
141  inline bool get_buffer_hint() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
142 
146  SetBit(GRPC_WRITE_BUFFER_HINT);
147  return *this;
148  }
149 
151  ClearBit(GRPC_WRITE_BUFFER_HINT);
152  return *this;
153  }
154 
155  inline bool is_corked() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
156 
163  last_message_ = true;
164  return *this;
165  }
166 
170  last_message_ = false;
171  return *this;
172  }
173 
177  SetBit(GRPC_WRITE_THROUGH);
178  return *this;
179  }
180 
181  inline bool is_write_through() const { return GetBit(GRPC_WRITE_THROUGH); }
182 
187  bool is_last_message() const { return last_message_; }
188 
190  flags_ = rhs.flags_;
191  return *this;
192  }
193 
194  private:
195  void SetBit(const uint32_t mask) { flags_ |= mask; }
196 
197  void ClearBit(const uint32_t mask) { flags_ &= ~mask; }
198 
199  bool GetBit(const uint32_t mask) const { return (flags_ & mask) != 0; }
200 
201  uint32_t flags_;
202  bool last_message_;
203 };
204 
205 namespace internal {
208 template <int I>
209 class CallNoOp {
210  protected:
211  void AddOp(grpc_op* ops, size_t* nops) {}
212  void FinishOp(bool* status) {}
213 };
214 
216  public:
218  maybe_compression_level_.is_set = false;
219  maybe_stream_compression_level_.is_set = false;
220  }
221 
223  const std::multimap<grpc::string, grpc::string>& metadata,
224  uint32_t flags) {
225  maybe_compression_level_.is_set = false;
226  maybe_stream_compression_level_.is_set = false;
227  send_ = true;
228  flags_ = flags;
231  }
232 
234  maybe_compression_level_.is_set = true;
236  }
237 
239  maybe_stream_compression_level_.is_set = true;
241  }
242 
243  protected:
244  void AddOp(grpc_op* ops, size_t* nops) {
245  if (!send_) return;
246  grpc_op* op = &ops[(*nops)++];
248  op->flags = flags_;
249  op->reserved = NULL;
254  if (maybe_compression_level_.is_set) {
257  }
260  if (maybe_stream_compression_level_.is_set) {
263  }
264  }
265  void FinishOp(bool* status) {
266  if (!send_) return;
268  send_ = false;
269  }
270 
271  bool send_;
272  uint32_t flags_;
275  struct {
276  bool is_set;
279  struct {
280  bool is_set;
283 };
284 
286  public:
287  CallOpSendMessage() : send_buf_() {}
288 
291  template <class M>
292  Status SendMessage(const M& message,
294 
295  template <class M>
296  Status SendMessage(const M& message) GRPC_MUST_USE_RESULT;
297 
298  protected:
299  void AddOp(grpc_op* ops, size_t* nops) {
300  if (!send_buf_.Valid()) return;
301  grpc_op* op = &ops[(*nops)++];
302  op->op = GRPC_OP_SEND_MESSAGE;
303  op->flags = write_options_.flags();
304  op->reserved = NULL;
305  op->data.send_message.send_message = send_buf_.c_buffer();
306  // Flags are per-message: clear them after use.
307  write_options_.Clear();
308  }
309  void FinishOp(bool* status) { send_buf_.Clear(); }
310 
311  private:
312  ByteBuffer send_buf_;
313  WriteOptions write_options_;
314 };
315 
316 template <class M>
318  write_options_ = options;
319  bool own_buf;
320  // TODO(vjpai): Remove the void below when possible
321  // The void in the template parameter below should not be needed
322  // (since it should be implicit) but is needed due to an observed
323  // difference in behavior between clang and gcc for certain internal users
325  message, send_buf_.bbuf_ptr(), &own_buf);
326  if (!own_buf) {
327  send_buf_.Duplicate();
328  }
329  return result;
330 }
331 
332 template <class M>
334  return SendMessage(message, WriteOptions());
335 }
336 
337 template <class R>
338 class CallOpRecvMessage {
339  public:
341  : got_message(false),
342  message_(nullptr),
343  allow_not_getting_message_(false) {}
344 
345  void RecvMessage(R* message) { message_ = message; }
346 
347  // Do not change status if no message is received.
348  void AllowNoMessage() { allow_not_getting_message_ = true; }
349 
351 
352  protected:
353  void AddOp(grpc_op* ops, size_t* nops) {
354  if (message_ == nullptr) return;
355  grpc_op* op = &ops[(*nops)++];
356  op->op = GRPC_OP_RECV_MESSAGE;
357  op->flags = 0;
358  op->reserved = NULL;
359  op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr();
360  }
361 
362  void FinishOp(bool* status) {
363  if (message_ == nullptr) return;
364  if (recv_buf_.Valid()) {
365  if (*status) {
366  got_message = *status =
367  SerializationTraits<R>::Deserialize(recv_buf_.bbuf_ptr(), message_)
368  .ok();
369  recv_buf_.Release();
370  } else {
371  got_message = false;
372  recv_buf_.Clear();
373  }
374  } else {
375  got_message = false;
376  if (!allow_not_getting_message_) {
377  *status = false;
378  }
379  }
380  message_ = nullptr;
381  }
382 
383  private:
384  R* message_;
385  ByteBuffer recv_buf_;
386  bool allow_not_getting_message_;
387 };
388 
390  public:
391  virtual Status Deserialize(ByteBuffer* buf) = 0;
392  virtual ~DeserializeFunc() {}
393 };
394 
395 template <class R>
396 class DeserializeFuncType final : public DeserializeFunc {
397  public:
398  DeserializeFuncType(R* message) : message_(message) {}
399  Status Deserialize(ByteBuffer* buf) override {
400  return SerializationTraits<R>::Deserialize(buf->bbuf_ptr(), message_);
401  }
402 
403  ~DeserializeFuncType() override {}
404 
405  private:
406  R* message_; // Not a managed pointer because management is external to this
407 };
408 
410  public:
412  : got_message(false), allow_not_getting_message_(false) {}
413 
414  template <class R>
415  void RecvMessage(R* message) {
416  // Use an explicit base class pointer to avoid resolution error in the
417  // following unique_ptr::reset for some old implementations.
418  DeserializeFunc* func = new DeserializeFuncType<R>(message);
419  deserialize_.reset(func);
420  }
421 
422  // Do not change status if no message is received.
423  void AllowNoMessage() { allow_not_getting_message_ = true; }
424 
426 
427  protected:
428  void AddOp(grpc_op* ops, size_t* nops) {
429  if (!deserialize_) return;
430  grpc_op* op = &ops[(*nops)++];
431  op->op = GRPC_OP_RECV_MESSAGE;
432  op->flags = 0;
433  op->reserved = NULL;
434  op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr();
435  }
436 
437  void FinishOp(bool* status) {
438  if (!deserialize_) return;
439  if (recv_buf_.Valid()) {
440  if (*status) {
441  got_message = true;
442  *status = deserialize_->Deserialize(&recv_buf_).ok();
443  recv_buf_.Release();
444  } else {
445  got_message = false;
446  recv_buf_.Clear();
447  }
448  } else {
449  got_message = false;
450  if (!allow_not_getting_message_) {
451  *status = false;
452  }
453  }
454  deserialize_.reset();
455  }
456 
457  private:
458  std::unique_ptr<DeserializeFunc> deserialize_;
459  ByteBuffer recv_buf_;
460  bool allow_not_getting_message_;
461 };
462 
464  public:
465  CallOpClientSendClose() : send_(false) {}
466 
467  void ClientSendClose() { send_ = true; }
468 
469  protected:
470  void AddOp(grpc_op* ops, size_t* nops) {
471  if (!send_) return;
472  grpc_op* op = &ops[(*nops)++];
474  op->flags = 0;
475  op->reserved = NULL;
476  }
477  void FinishOp(bool* status) { send_ = false; }
478 
479  private:
480  bool send_;
481 };
482 
484  public:
485  CallOpServerSendStatus() : send_status_available_(false) {}
486 
488  const std::multimap<grpc::string, grpc::string>& trailing_metadata,
489  const Status& status) {
490  send_error_details_ = status.error_details();
491  trailing_metadata_ = FillMetadataArray(
492  trailing_metadata, &trailing_metadata_count_, send_error_details_);
493  send_status_available_ = true;
494  send_status_code_ = static_cast<grpc_status_code>(status.error_code());
495  send_error_message_ = status.error_message();
496  }
497 
498  protected:
499  void AddOp(grpc_op* ops, size_t* nops) {
500  if (!send_status_available_) return;
501  grpc_op* op = &ops[(*nops)++];
504  trailing_metadata_count_;
505  op->data.send_status_from_server.trailing_metadata = trailing_metadata_;
506  op->data.send_status_from_server.status = send_status_code_;
507  error_message_slice_ = SliceReferencingString(send_error_message_);
509  send_error_message_.empty() ? nullptr : &error_message_slice_;
510  op->flags = 0;
511  op->reserved = NULL;
512  }
513 
514  void FinishOp(bool* status) {
515  if (!send_status_available_) return;
516  g_core_codegen_interface->gpr_free(trailing_metadata_);
517  send_status_available_ = false;
518  }
519 
520  private:
521  bool send_status_available_;
522  grpc_status_code send_status_code_;
523  grpc::string send_error_details_;
524  grpc::string send_error_message_;
525  size_t trailing_metadata_count_;
526  grpc_metadata* trailing_metadata_;
527  grpc_slice error_message_slice_;
528 };
529 
531  public:
532  CallOpRecvInitialMetadata() : metadata_map_(nullptr) {}
533 
535  context->initial_metadata_received_ = true;
536  metadata_map_ = &context->recv_initial_metadata_;
537  }
538 
539  protected:
540  void AddOp(grpc_op* ops, size_t* nops) {
541  if (metadata_map_ == nullptr) return;
542  grpc_op* op = &ops[(*nops)++];
544  op->data.recv_initial_metadata.recv_initial_metadata = metadata_map_->arr();
545  op->flags = 0;
546  op->reserved = NULL;
547  }
548 
549  void FinishOp(bool* status) {
550  if (metadata_map_ == nullptr) return;
551  metadata_map_->FillMap();
552  metadata_map_ = nullptr;
553  }
554 
555  private:
556  MetadataMap* metadata_map_;
557 };
558 
560  public:
562  : recv_status_(nullptr), debug_error_string_(nullptr) {}
563 
564  void ClientRecvStatus(ClientContext* context, Status* status) {
565  client_context_ = context;
566  metadata_map_ = &client_context_->trailing_metadata_;
567  recv_status_ = status;
568  error_message_ = g_core_codegen_interface->grpc_empty_slice();
569  }
570 
571  protected:
572  void AddOp(grpc_op* ops, size_t* nops) {
573  if (recv_status_ == nullptr) return;
574  grpc_op* op = &ops[(*nops)++];
576  op->data.recv_status_on_client.trailing_metadata = metadata_map_->arr();
577  op->data.recv_status_on_client.status = &status_code_;
578  op->data.recv_status_on_client.status_details = &error_message_;
579  op->data.recv_status_on_client.error_string = &debug_error_string_;
580  op->flags = 0;
581  op->reserved = NULL;
582  }
583 
584  void FinishOp(bool* status) {
585  if (recv_status_ == nullptr) return;
586  metadata_map_->FillMap();
587  grpc::string binary_error_details;
588  auto iter = metadata_map_->map()->find(kBinaryErrorDetailsKey);
589  if (iter != metadata_map_->map()->end()) {
590  binary_error_details =
591  grpc::string(iter->second.begin(), iter->second.length());
592  }
593  *recv_status_ = Status(static_cast<StatusCode>(status_code_),
594  grpc::string(GRPC_SLICE_START_PTR(error_message_),
595  GRPC_SLICE_END_PTR(error_message_)),
596  binary_error_details);
597  client_context_->set_debug_error_string(
598  debug_error_string_ != nullptr ? debug_error_string_ : "");
600  if (debug_error_string_ != nullptr) {
601  g_core_codegen_interface->gpr_free((void*)debug_error_string_);
602  }
603  recv_status_ = nullptr;
604  }
605 
606  private:
607  ClientContext* client_context_;
608  MetadataMap* metadata_map_;
609  Status* recv_status_;
610  const char* debug_error_string_;
611  grpc_status_code status_code_;
612  grpc_slice error_message_;
613 };
614 
621  public:
624  virtual void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) = 0;
625 };
626 
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>>
637  public Op1,
638  public Op2,
639  public Op3,
640  public Op4,
641  public Op5,
642  public Op6 {
643  public:
644  CallOpSet() : return_tag_(this) {}
645  void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) override {
646  this->Op1::AddOp(ops, nops);
647  this->Op2::AddOp(ops, nops);
648  this->Op3::AddOp(ops, nops);
649  this->Op4::AddOp(ops, nops);
650  this->Op5::AddOp(ops, nops);
651  this->Op6::AddOp(ops, nops);
653  call_ = call;
654  }
655 
656  bool FinalizeResult(void** tag, bool* status) override {
657  this->Op1::FinishOp(status);
658  this->Op2::FinishOp(status);
659  this->Op3::FinishOp(status);
660  this->Op4::FinishOp(status);
661  this->Op5::FinishOp(status);
662  this->Op6::FinishOp(status);
663  *tag = return_tag_;
664 
666  return true;
667  }
668 
669  void set_output_tag(void* return_tag) { return_tag_ = return_tag; }
670 
671  private:
672  void* return_tag_;
673  grpc_call* call_;
674 };
675 
680 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
681  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
682  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
683 class SneakyCallOpSet : public CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> {
684  public:
685  bool FinalizeResult(void** tag, bool* status) override {
687  return Base::FinalizeResult(tag, status) && false;
688  }
689 };
690 
692 class Call final {
693  public:
696  : call_hook_(call_hook),
697  cq_(cq),
698  call_(call),
699  max_receive_message_size_(-1) {}
700 
703  : call_hook_(call_hook),
704  cq_(cq),
705  call_(call),
706  max_receive_message_size_(max_receive_message_size) {}
707 
709  call_hook_->PerformOpsOnCall(ops, this);
710  }
711 
712  grpc_call* call() const { return call_; }
713  CompletionQueue* cq() const { return cq_; }
714 
715  int max_receive_message_size() const { return max_receive_message_size_; }
716 
717  private:
718  CallHook* call_hook_;
719  CompletionQueue* cq_;
720  grpc_call* call_;
721  int max_receive_message_size_;
722 };
723 } // namespace internal
724 } // namespace grpc
725 
726 #endif // GRPCXX_IMPL_CODEGEN_CALL_H
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:70
grpc_op_type op
Operation type, as defined by grpc_op_type.
Definition: grpc_types.h:499
void Clear()
Remove all data.
Definition: byte_buffer.h:72
grpc_metadata_array * recv_initial_metadata
Definition: grpc_types.h:546
union grpc_op::grpc_op_data data
struct grpc_op::grpc_op_data::grpc_op_send_initial_metadata::grpc_op_send_initial_metadata_maybe_stream_compression_level maybe_stream_compression_level
bool is_corked() const
Definition: call.h:155
void * reserved
Reserved for future usage.
Definition: grpc_types.h:503
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:132
grpc_status_code
Definition: status.h:26
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:123
void FinishOp(bool *status)
Definition: call.h:514
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:540
void ClientSendClose()
Definition: call.h:467
virtual void grpc_call_ref(grpc_call *call)=0
grpc::string error_message() const
Return the instance's error message.
Definition: status.h:58
CallOpRecvMessage()
Definition: call.h:340
std::string string
Definition: config.h:35
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call.h:106
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:552
void FinishOp(bool *status)
Definition: call.h:549
struct grpc_byte_buffer * send_message
This op takes ownership of the slices in send_message.
Definition: grpc_types.h:529
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:464
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:469
An interface allowing implementors to process and filter event tags.
Definition: completion_queue_tag.h:26
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:299
void AllowNoMessage()
Definition: call.h:423
Definition: metadata_map.h:27
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:162
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:364
grpc_slice key
the key, value values are expected to line up with grpc_mdelem: if changing them, update metadata...
Definition: grpc_types.h:396
Status Deserialize(ByteBuffer *buf) override
Definition: call.h:399
CallOpRecvInitialMetadata()
Definition: call.h:532
grpc_stream_compression_level
Compression levels for stream compression algorithms.
Definition: compression_types.h:106
struct grpc_op::grpc_op_data::grpc_op_recv_message recv_message
Primary implementaiton of CallOpSetInterface.
Definition: call.h:636
grpc_slice value
Definition: grpc_types.h:397
#define GRPC_WRITE_THROUGH
Force this message to be written to the socket before completing it.
Definition: grpc_types.h:366
const char ** error_string
If this is not nullptr, it will be populated with the full fidelity error string for debugging purpos...
Definition: grpc_types.h:566
grpc_slice * status_details
Definition: grpc_types.h:562
void Clear()
Clear all flags.
Definition: call.h:90
virtual grpc_slice grpc_empty_slice()=0
WriteOptions & set_write_through()
Guarantee that all bytes have been written to the wire before completing this write (usually writes a...
Definition: call.h:176
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. ...
Definition: slice.h:80
bool send_
Definition: call.h:271
#define GRPC_WRITE_BUFFER_HINT
Write Flags:
Definition: grpc_types.h:361
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
call is owned by the caller
Definition: call.h:695
void RecvInitialMetadata(ClientContext *context)
Definition: call.h:534
struct grpc::internal::CallOpSendInitialMetadata::@1 maybe_stream_compression_level_
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:459
bool got_message
Definition: call.h:350
virtual void grpc_call_unref(grpc_call *call)=0
void Duplicate()
Make a duplicate copy of the internals of this byte buffer so that we have our own owned version of i...
Definition: byte_buffer.h:82
WriteOptions()
Definition: call.h:85
WriteOptions & clear_last_message()
Clears flag indicating that this is the last message in a stream, disabling coalescing.
Definition: call.h:169
grpc_slice SliceReferencingString(const grpc::string &str)
Definition: slice.h:116
struct grpc_op::grpc_op_data::grpc_op_send_initial_metadata::grpc_op_send_initial_metadata_maybe_compression_level maybe_compression_level
void ClientRecvStatus(ClientContext *context, Status *status)
Definition: call.h:564
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:97
uint32_t flags() const
Returns raw flags bitset.
Definition: call.h:93
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:116
bool is_write_through() const
Definition: call.h:181
bool is_set
Definition: call.h:276
grpc_metadata_array * trailing_metadata
ownership of the array is with the caller, but ownership of the elements stays with the call object (...
Definition: grpc_types.h:560
WriteOptions & clear_corked()
Definition: call.h:150
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call.h:98
#define GRPC_SLICE_END_PTR(slice)
Definition: slice.h:125
CallOpClientSendClose()
Definition: call.h:465
void FinishOp(bool *status)
Definition: call.h:265
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:162
WriteOptions & operator=(const WriteOptions &rhs)
Definition: call.h:189
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:572
Definition: byte_buffer.h:45
uint32_t flags_
Definition: call.h:272
int max_receive_message_size() const
Definition: call.h:715
bool Valid() const
Is this ByteBuffer valid?
Definition: byte_buffer.h:97
Default argument for CallOpSet.
Definition: call.h:209
void FinishOp(bool *status)
Definition: call.h:584
grpc_compression_level level
Definition: call.h:277
A CallOpSet that does not post completions to the completion queue.
Definition: call.h:683
bool got_message
Definition: call.h:425
Definition: call.h:389
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:58
void set_stream_compression_level(grpc_stream_compression_level level)
Definition: call.h:238
virtual void FillOps(grpc_call *call, grpc_op *ops, size_t *nops)=0
Fills in grpc_op, starting from ops[*nops] and moving upwards.
CallOpServerSendStatus()
Definition: call.h:485
bool FinalizeResult(void **tag, bool *status) override
Called prior to returning from Next(), return value is the status of the operation (return status is ...
Definition: call.h:656
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call.h:115
void set_compression_level(grpc_compression_level level)
Definition: call.h:233
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:428
void Release()
Forget underlying byte buffer without destroying Use this only for un-owned byte buffers.
Definition: byte_buffer.h:88
Status SendMessage(const M &message, WriteOptions options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:317
grpc_metadata * FillMetadataArray(const std::multimap< grpc::string, grpc::string > &metadata, size_t *metadata_count, const grpc::string &optional_error_details)
Definition: call.h:57
struct grpc_op::grpc_op_data::grpc_op_recv_initial_metadata recv_initial_metadata
A single metadata element.
Definition: grpc_types.h:393
Definition: call.h:285
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_receive_message_size)
Definition: call.h:701
std::multimap< grpc::string_ref, grpc::string_ref > * map()
Definition: metadata_map.h:44
struct grpc_op::grpc_op_data::grpc_op_send_initial_metadata send_initial_metadata
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:244
void FinishOp(bool *status)
Definition: call.h:437
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:497
virtual void PerformOpsOnCall(CallOpSetInterface *ops, Call *call)=0
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:474
void RecvMessage(R *message)
Definition: call.h:415
struct grpc_op::grpc_op_data::grpc_op_send_message send_message
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:46
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:499
#define GRPC_MUST_USE_RESULT
Definition: port_platform.h:432
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:455
WriteOptions(const WriteOptions &other)
Definition: call.h:86
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:470
CallOpClientRecvStatus()
Definition: call.h:561
Definition: byte_buffer.h:37
void SendInitialMetadata(const std::multimap< grpc::string, grpc::string > &metadata, uint32_t flags)
Definition: call.h:222
void FinishOp(bool *status)
Definition: call.h:477
Per-message write options.
Definition: call.h:83
struct grpc::internal::CallOpSendInitialMetadata::@0 maybe_compression_level_
grpc_slice * status_details
optional: set to NULL if no details need sending, non-NULL if they do pointer will not be retained pa...
Definition: grpc_types.h:538
void AllowNoMessage()
Definition: call.h:348
size_t trailing_metadata_count
Definition: grpc_types.h:532
CallOpSendMessage()
Definition: call.h:287
grpc_metadata * metadata
Definition: grpc_types.h:511
grpc_metadata_array * arr()
Definition: metadata_map.h:48
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:141
void FinishOp(bool *status)
Definition: call.h:212
StatusCode error_code() const
Return the instance's error code.
Definition: status.h:56
void FinishOp(bool *status)
Definition: call.h:362
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:94
grpc_call * call() const
Definition: call.h:712
virtual Status Deserialize(ByteBuffer *buf)=0
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:620
void FillOps(grpc_call *call, grpc_op *ops, size_t *nops) override
Fills in grpc_op, starting from ops[*nops] and moving upwards.
Definition: call.h:645
void FillMap()
Definition: metadata_map.h:35
virtual void grpc_slice_unref(grpc_slice slice)=0
void ServerSendStatus(const std::multimap< grpc::string, grpc::string > &trailing_metadata, const Status &status)
Definition: call.h:487
virtual ~DeserializeFunc()
Definition: call.h:392
void RecvMessage(R *message)
Definition: call.h:345
grpc::string error_details() const
Return the (binary) error details.
Definition: status.h:61
struct grpc_op::grpc_op_data::grpc_op_send_status_from_server send_status_from_server
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:37
void set_output_tag(void *return_tag)
Definition: call.h:669
CallOpSendInitialMetadata()
Definition: call.h:217
WriteOptions & set_corked()
corked bit: aliases set_buffer_hint currently, with the intent that set_buffer_hint will be removed i...
Definition: call.h:145
bool FinalizeResult(void **tag, bool *status) override
Called prior to returning from Next(), return value is the status of the operation (return status is ...
Definition: call.h:685
CompletionQueue * cq() const
Definition: call.h:713
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:211
Did it work? If it didn't, why?
Definition: status.h:30
void FinishOp(bool *status)
Definition: call.h:309
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:484
grpc_metadata * initial_metadata_
Definition: call.h:274
grpc_stream_compression_level level
Definition: call.h:281
DeserializeFuncType(R *message)
Definition: call.h:398
size_t initial_metadata_count_
Definition: call.h:273
grpc_status_code status
Definition: grpc_types.h:534
grpc_status_code * status
Definition: grpc_types.h:561
size_t count
Definition: grpc_types.h:510
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:708
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:501
virtual void gpr_free(void *p)=0
This is an interface that Channel and Server implement to allow them to hook performing ops...
Definition: call_hook.h:30
Receive a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:478
A sequence of bytes.
Definition: byte_buffer.h:48
CallOpGenericRecvMessage()
Definition: call.h:411
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:353
CallOpSet()
Definition: call.h:644
const char kBinaryErrorDetailsKey[]
Definition: call.h:53
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:187
Straightforward wrapping of the C call object.
Definition: call.h:692
grpc_metadata * trailing_metadata
Definition: grpc_types.h:533
struct grpc_op::grpc_op_data::grpc_op_recv_status_on_client recv_status_on_client
virtual void * gpr_malloc(size_t size)=0
~DeserializeFuncType() override
Definition: call.h:403