GRPC C++  1.16.0-dev
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 GRPCPP_IMPL_CODEGEN_CALL_H
20 #define GRPCPP_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 // TODO(yangg) if the map is changed before we send, the pointers will be a
54 // mess. Make sure it does not happen.
56  const std::multimap<grpc::string, grpc::string>& metadata,
57  size_t* metadata_count, const grpc::string& optional_error_details) {
58  *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1);
59  if (*metadata_count == 0) {
60  return nullptr;
61  }
62  grpc_metadata* metadata_array =
63  (grpc_metadata*)(g_core_codegen_interface->gpr_malloc(
64  (*metadata_count) * sizeof(grpc_metadata)));
65  size_t i = 0;
66  for (auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
67  metadata_array[i].key = SliceReferencingString(iter->first);
68  metadata_array[i].value = SliceReferencingString(iter->second);
69  }
70  if (!optional_error_details.empty()) {
71  metadata_array[i].key =
72  g_core_codegen_interface->grpc_slice_from_static_buffer(
74  metadata_array[i].value = SliceReferencingString(optional_error_details);
75  }
76  return metadata_array;
77 }
78 } // namespace internal
79 
81 class WriteOptions {
82  public:
83  WriteOptions() : flags_(0), last_message_(false) {}
84  WriteOptions(const WriteOptions& other)
85  : flags_(other.flags_), last_message_(other.last_message_) {}
86 
88  inline void Clear() { flags_ = 0; }
89 
91  inline uint32_t flags() const { return flags_; }
92 
97  SetBit(GRPC_WRITE_NO_COMPRESS);
98  return *this;
99  }
100 
105  ClearBit(GRPC_WRITE_NO_COMPRESS);
106  return *this;
107  }
108 
113  inline bool get_no_compression() const {
114  return GetBit(GRPC_WRITE_NO_COMPRESS);
115  }
116 
122  SetBit(GRPC_WRITE_BUFFER_HINT);
123  return *this;
124  }
125 
131  ClearBit(GRPC_WRITE_BUFFER_HINT);
132  return *this;
133  }
134 
139  inline bool get_buffer_hint() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
140 
144  SetBit(GRPC_WRITE_BUFFER_HINT);
145  return *this;
146  }
147 
149  ClearBit(GRPC_WRITE_BUFFER_HINT);
150  return *this;
151  }
152 
153  inline bool is_corked() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
154 
161  last_message_ = true;
162  return *this;
163  }
164 
168  last_message_ = false;
169  return *this;
170  }
171 
175  SetBit(GRPC_WRITE_THROUGH);
176  return *this;
177  }
178 
179  inline bool is_write_through() const { return GetBit(GRPC_WRITE_THROUGH); }
180 
185  bool is_last_message() const { return last_message_; }
186 
188  flags_ = rhs.flags_;
189  return *this;
190  }
191 
192  private:
193  void SetBit(const uint32_t mask) { flags_ |= mask; }
194 
195  void ClearBit(const uint32_t mask) { flags_ &= ~mask; }
196 
197  bool GetBit(const uint32_t mask) const { return (flags_ & mask) != 0; }
198 
199  uint32_t flags_;
200  bool last_message_;
201 };
202 
203 namespace internal {
206 template <int I>
207 class CallNoOp {
208  protected:
209  void AddOp(grpc_op* ops, size_t* nops) {}
210  void FinishOp(bool* status) {}
211 };
212 
214  public:
215  CallOpSendInitialMetadata() : send_(false) {
216  maybe_compression_level_.is_set = false;
217  }
218 
220  const std::multimap<grpc::string, grpc::string>& metadata,
221  uint32_t flags) {
222  maybe_compression_level_.is_set = false;
223  send_ = true;
224  flags_ = flags;
225  initial_metadata_ =
226  FillMetadataArray(metadata, &initial_metadata_count_, "");
227  }
228 
230  maybe_compression_level_.is_set = true;
231  maybe_compression_level_.level = level;
232  }
233 
234  protected:
235  void AddOp(grpc_op* ops, size_t* nops) {
236  if (!send_) return;
237  grpc_op* op = &ops[(*nops)++];
239  op->flags = flags_;
240  op->reserved = NULL;
241  op->data.send_initial_metadata.count = initial_metadata_count_;
242  op->data.send_initial_metadata.metadata = initial_metadata_;
244  maybe_compression_level_.is_set;
245  if (maybe_compression_level_.is_set) {
247  maybe_compression_level_.level;
248  }
249  }
250  void FinishOp(bool* status) {
251  if (!send_) return;
252  g_core_codegen_interface->gpr_free(initial_metadata_);
253  send_ = false;
254  }
255 
256  bool send_;
257  uint32_t flags_;
260  struct {
261  bool is_set;
263  } maybe_compression_level_;
264 };
265 
267  public:
268  CallOpSendMessage() : send_buf_() {}
269 
272  template <class M>
273  Status SendMessage(const M& message,
275 
276  template <class M>
277  Status SendMessage(const M& message) GRPC_MUST_USE_RESULT;
278 
279  protected:
280  void AddOp(grpc_op* ops, size_t* nops) {
281  if (!send_buf_.Valid()) return;
282  grpc_op* op = &ops[(*nops)++];
283  op->op = GRPC_OP_SEND_MESSAGE;
284  op->flags = write_options_.flags();
285  op->reserved = NULL;
286  op->data.send_message.send_message = send_buf_.c_buffer();
287  // Flags are per-message: clear them after use.
288  write_options_.Clear();
289  }
290  void FinishOp(bool* status) { send_buf_.Clear(); }
291 
292  private:
293  ByteBuffer send_buf_;
294  WriteOptions write_options_;
295 };
296 
297 template <class M>
299  write_options_ = options;
300  bool own_buf;
301  // TODO(vjpai): Remove the void below when possible
302  // The void in the template parameter below should not be needed
303  // (since it should be implicit) but is needed due to an observed
304  // difference in behavior between clang and gcc for certain internal users
306  message, send_buf_.bbuf_ptr(), &own_buf);
307  if (!own_buf) {
308  send_buf_.Duplicate();
309  }
310  return result;
311 }
312 
313 template <class M>
315  return SendMessage(message, WriteOptions());
316 }
317 
318 template <class R>
319 class CallOpRecvMessage {
320  public:
322  : got_message(false),
323  message_(nullptr),
324  allow_not_getting_message_(false) {}
325 
326  void RecvMessage(R* message) { message_ = message; }
327 
328  // Do not change status if no message is received.
329  void AllowNoMessage() { allow_not_getting_message_ = true; }
330 
332 
333  protected:
334  void AddOp(grpc_op* ops, size_t* nops) {
335  if (message_ == nullptr) return;
336  grpc_op* op = &ops[(*nops)++];
337  op->op = GRPC_OP_RECV_MESSAGE;
338  op->flags = 0;
339  op->reserved = NULL;
340  op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr();
341  }
342 
343  void FinishOp(bool* status) {
344  if (message_ == nullptr) return;
345  if (recv_buf_.Valid()) {
346  if (*status) {
347  got_message = *status =
348  SerializationTraits<R>::Deserialize(recv_buf_.bbuf_ptr(), message_)
349  .ok();
350  recv_buf_.Release();
351  } else {
352  got_message = false;
353  recv_buf_.Clear();
354  }
355  } else {
356  got_message = false;
357  if (!allow_not_getting_message_) {
358  *status = false;
359  }
360  }
361  message_ = nullptr;
362  }
363 
364  private:
365  R* message_;
366  ByteBuffer recv_buf_;
367  bool allow_not_getting_message_;
368 };
369 
371  public:
372  virtual Status Deserialize(ByteBuffer* buf) = 0;
373  virtual ~DeserializeFunc() {}
374 };
375 
376 template <class R>
377 class DeserializeFuncType final : public DeserializeFunc {
378  public:
379  DeserializeFuncType(R* message) : message_(message) {}
380  Status Deserialize(ByteBuffer* buf) override {
381  return SerializationTraits<R>::Deserialize(buf->bbuf_ptr(), message_);
382  }
383 
384  ~DeserializeFuncType() override {}
385 
386  private:
387  R* message_; // Not a managed pointer because management is external to this
388 };
389 
391  public:
393  : got_message(false), allow_not_getting_message_(false) {}
394 
395  template <class R>
396  void RecvMessage(R* message) {
397  // Use an explicit base class pointer to avoid resolution error in the
398  // following unique_ptr::reset for some old implementations.
399  DeserializeFunc* func = new DeserializeFuncType<R>(message);
400  deserialize_.reset(func);
401  }
402 
403  // Do not change status if no message is received.
404  void AllowNoMessage() { allow_not_getting_message_ = true; }
405 
407 
408  protected:
409  void AddOp(grpc_op* ops, size_t* nops) {
410  if (!deserialize_) return;
411  grpc_op* op = &ops[(*nops)++];
412  op->op = GRPC_OP_RECV_MESSAGE;
413  op->flags = 0;
414  op->reserved = NULL;
415  op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr();
416  }
417 
418  void FinishOp(bool* status) {
419  if (!deserialize_) return;
420  if (recv_buf_.Valid()) {
421  if (*status) {
422  got_message = true;
423  *status = deserialize_->Deserialize(&recv_buf_).ok();
424  recv_buf_.Release();
425  } else {
426  got_message = false;
427  recv_buf_.Clear();
428  }
429  } else {
430  got_message = false;
431  if (!allow_not_getting_message_) {
432  *status = false;
433  }
434  }
435  deserialize_.reset();
436  }
437 
438  private:
439  std::unique_ptr<DeserializeFunc> deserialize_;
440  ByteBuffer recv_buf_;
441  bool allow_not_getting_message_;
442 };
443 
445  public:
446  CallOpClientSendClose() : send_(false) {}
447 
448  void ClientSendClose() { send_ = true; }
449 
450  protected:
451  void AddOp(grpc_op* ops, size_t* nops) {
452  if (!send_) return;
453  grpc_op* op = &ops[(*nops)++];
455  op->flags = 0;
456  op->reserved = NULL;
457  }
458  void FinishOp(bool* status) { send_ = false; }
459 
460  private:
461  bool send_;
462 };
463 
465  public:
466  CallOpServerSendStatus() : send_status_available_(false) {}
467 
469  const std::multimap<grpc::string, grpc::string>& trailing_metadata,
470  const Status& status) {
471  send_error_details_ = status.error_details();
472  trailing_metadata_ = FillMetadataArray(
473  trailing_metadata, &trailing_metadata_count_, send_error_details_);
474  send_status_available_ = true;
475  send_status_code_ = static_cast<grpc_status_code>(status.error_code());
476  send_error_message_ = status.error_message();
477  }
478 
479  protected:
480  void AddOp(grpc_op* ops, size_t* nops) {
481  if (!send_status_available_) return;
482  grpc_op* op = &ops[(*nops)++];
485  trailing_metadata_count_;
486  op->data.send_status_from_server.trailing_metadata = trailing_metadata_;
487  op->data.send_status_from_server.status = send_status_code_;
488  error_message_slice_ = SliceReferencingString(send_error_message_);
490  send_error_message_.empty() ? nullptr : &error_message_slice_;
491  op->flags = 0;
492  op->reserved = NULL;
493  }
494 
495  void FinishOp(bool* status) {
496  if (!send_status_available_) return;
497  g_core_codegen_interface->gpr_free(trailing_metadata_);
498  send_status_available_ = false;
499  }
500 
501  private:
502  bool send_status_available_;
503  grpc_status_code send_status_code_;
504  grpc::string send_error_details_;
505  grpc::string send_error_message_;
506  size_t trailing_metadata_count_;
507  grpc_metadata* trailing_metadata_;
508  grpc_slice error_message_slice_;
509 };
510 
512  public:
513  CallOpRecvInitialMetadata() : metadata_map_(nullptr) {}
514 
516  context->initial_metadata_received_ = true;
517  metadata_map_ = &context->recv_initial_metadata_;
518  }
519 
520  protected:
521  void AddOp(grpc_op* ops, size_t* nops) {
522  if (metadata_map_ == nullptr) return;
523  grpc_op* op = &ops[(*nops)++];
525  op->data.recv_initial_metadata.recv_initial_metadata = metadata_map_->arr();
526  op->flags = 0;
527  op->reserved = NULL;
528  }
529 
530  void FinishOp(bool* status) {
531  if (metadata_map_ == nullptr) return;
532  metadata_map_ = nullptr;
533  }
534 
535  private:
536  MetadataMap* metadata_map_;
537 };
538 
540  public:
542  : recv_status_(nullptr), debug_error_string_(nullptr) {}
543 
544  void ClientRecvStatus(ClientContext* context, Status* status) {
545  client_context_ = context;
546  metadata_map_ = &client_context_->trailing_metadata_;
547  recv_status_ = status;
548  error_message_ = g_core_codegen_interface->grpc_empty_slice();
549  }
550 
551  protected:
552  void AddOp(grpc_op* ops, size_t* nops) {
553  if (recv_status_ == nullptr) return;
554  grpc_op* op = &ops[(*nops)++];
556  op->data.recv_status_on_client.trailing_metadata = metadata_map_->arr();
557  op->data.recv_status_on_client.status = &status_code_;
558  op->data.recv_status_on_client.status_details = &error_message_;
559  op->data.recv_status_on_client.error_string = &debug_error_string_;
560  op->flags = 0;
561  op->reserved = NULL;
562  }
563 
564  void FinishOp(bool* status) {
565  if (recv_status_ == nullptr) return;
566  grpc::string binary_error_details = metadata_map_->GetBinaryErrorDetails();
567  *recv_status_ =
568  Status(static_cast<StatusCode>(status_code_),
569  GRPC_SLICE_IS_EMPTY(error_message_)
570  ? grpc::string()
571  : grpc::string(GRPC_SLICE_START_PTR(error_message_),
572  GRPC_SLICE_END_PTR(error_message_)),
573  binary_error_details);
574  client_context_->set_debug_error_string(
575  debug_error_string_ != nullptr ? debug_error_string_ : "");
576  g_core_codegen_interface->grpc_slice_unref(error_message_);
577  if (debug_error_string_ != nullptr) {
578  g_core_codegen_interface->gpr_free((void*)debug_error_string_);
579  }
580  recv_status_ = nullptr;
581  }
582 
583  private:
584  ClientContext* client_context_;
585  MetadataMap* metadata_map_;
586  Status* recv_status_;
587  const char* debug_error_string_;
588  grpc_status_code status_code_;
589  grpc_slice error_message_;
590 };
591 
598  public:
601  virtual void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) = 0;
602 
606  virtual void* cq_tag() = 0;
607 };
608 
615 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
616  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
617  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
619  public Op1,
620  public Op2,
621  public Op3,
622  public Op4,
623  public Op5,
624  public Op6 {
625  public:
626  CallOpSet() : cq_tag_(this), return_tag_(this), call_(nullptr) {}
627  void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) override {
628  this->Op1::AddOp(ops, nops);
629  this->Op2::AddOp(ops, nops);
630  this->Op3::AddOp(ops, nops);
631  this->Op4::AddOp(ops, nops);
632  this->Op5::AddOp(ops, nops);
633  this->Op6::AddOp(ops, nops);
634  g_core_codegen_interface->grpc_call_ref(call);
635  call_ = call;
636  }
637 
638  bool FinalizeResult(void** tag, bool* status) override {
639  this->Op1::FinishOp(status);
640  this->Op2::FinishOp(status);
641  this->Op3::FinishOp(status);
642  this->Op4::FinishOp(status);
643  this->Op5::FinishOp(status);
644  this->Op6::FinishOp(status);
645  *tag = return_tag_;
646 
647  g_core_codegen_interface->grpc_call_unref(call_);
648  return true;
649  }
650 
651  void set_output_tag(void* return_tag) { return_tag_ = return_tag; }
652 
653  void* cq_tag() override { return cq_tag_; }
654 
659  void set_cq_tag(void* cq_tag) { cq_tag_ = cq_tag; }
660 
661  private:
662  void* cq_tag_;
663  void* return_tag_;
664  grpc_call* call_;
665 };
666 
668 class Call final {
669  public:
671  Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq)
672  : call_hook_(call_hook),
673  cq_(cq),
674  call_(call),
675  max_receive_message_size_(-1) {}
676 
677  Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq,
678  int max_receive_message_size)
679  : call_hook_(call_hook),
680  cq_(cq),
681  call_(call),
682  max_receive_message_size_(max_receive_message_size) {}
683 
685  call_hook_->PerformOpsOnCall(ops, this);
686  }
687 
688  grpc_call* call() const { return call_; }
689  CompletionQueue* cq() const { return cq_; }
690 
691  int max_receive_message_size() const { return max_receive_message_size_; }
692 
693  private:
694  CallHook* call_hook_;
695  CompletionQueue* cq_;
696  grpc_call* call_;
697  int max_receive_message_size_;
698 };
699 } // namespace internal
700 } // namespace grpc
701 
702 #endif // GRPCPP_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:538
grpc_metadata_array * recv_initial_metadata
Definition: grpc_types.h:581
union grpc_op::grpc_op_data data
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call.h:113
void * reserved
Reserved for future usage.
Definition: grpc_types.h:542
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:130
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:121
void FinishOp(bool *status)
Definition: call.h:495
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:521
void ClientSendClose()
Definition: call.h:448
virtual void grpc_call_ref(grpc_call *call)=0
CallOpRecvMessage()
Definition: call.h:321
std::string string
Definition: config.h:35
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:139
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call.h:104
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:589
void FinishOp(bool *status)
Definition: call.h:530
struct grpc_byte_buffer * send_message
This op takes ownership of the slices in send_message.
Definition: grpc_types.h:564
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:503
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:508
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:280
void AllowNoMessage()
Definition: call.h:404
Definition: metadata_map.h:31
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call.h:160
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:403
grpc_slice key
the key, value values are expected to line up with grpc_mdelem: if changing them, update metadata...
Definition: grpc_types.h:435
Status Deserialize(ByteBuffer *buf) override
Definition: call.h:380
CallOpRecvInitialMetadata()
Definition: call.h:513
struct grpc_op::grpc_op_data::grpc_op_recv_message recv_message
Primary implementation of CallOpSetInterface.
Definition: call.h:618
#define GRPC_SLICE_IS_EMPTY(slice)
Definition: slice.h:127
grpc_slice value
Definition: grpc_types.h:436
#define GRPC_WRITE_THROUGH
Force this message to be written to the socket before completing it.
Definition: grpc_types.h:405
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:603
grpc_slice * status_details
Definition: grpc_types.h:599
void Clear()
Clear all flags.
Definition: call.h:88
virtual grpc_slice grpc_empty_slice()=0
WriteOptions & set_write_through()
Guarantee that all bytes have been written to the socket before completing this write (usually writes...
Definition: call.h:174
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:256
#define GRPC_WRITE_BUFFER_HINT
Write Flags:
Definition: grpc_types.h:400
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
call is owned by the caller
Definition: call.h:671
void RecvInitialMetadata(ClientContext *context)
Definition: call.h:515
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:498
bool got_message
Definition: call.h:331
virtual void grpc_call_unref(grpc_call *call)=0
CompletionQueue * cq() const
Definition: call.h:689
bool is_write_through() const
Definition: call.h:179
WriteOptions()
Definition: call.h:83
WriteOptions & clear_last_message()
Clears flag indicating that this is the last message in a stream, disabling coalescing.
Definition: call.h:167
grpc_slice SliceReferencingString(const grpc::string &str)
Definition: slice.h:131
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:544
grpc_compression_level
Compression levels allow a party with knowledge of its peer&#39;s accepted encodings to request compressi...
Definition: compression_types.h:70
grpc_call * call() const
Definition: call.h:688
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:116
bool is_set
Definition: call.h:261
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:597
WriteOptions & clear_corked()
Definition: call.h:148
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call.h:96
#define GRPC_SLICE_END_PTR(slice)
Definition: slice.h:125
CallOpClientSendClose()
Definition: call.h:446
void FinishOp(bool *status)
Definition: call.h:250
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:164
WriteOptions & operator=(const WriteOptions &rhs)
Definition: call.h:187
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:552
Definition: byte_buffer.h:51
uint32_t flags_
Definition: call.h:257
Default argument for CallOpSet.
Definition: call.h:207
void FinishOp(bool *status)
Definition: call.h:564
grpc_compression_level level
Definition: call.h:262
bool got_message
Definition: call.h:406
grpc::string error_message() const
Return the instance&#39;s error message.
Definition: status.h:112
Definition: call.h:370
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:58
StatusCode error_code() const
Return the instance&#39;s error code.
Definition: status.h:110
CallOpServerSendStatus()
Definition: call.h:466
bool FinalizeResult(void **tag, bool *status) override
FinalizeResult must be called before informing user code that the operation bound to the underlying c...
Definition: call.h:638
void set_compression_level(grpc_compression_level level)
Definition: call.h:229
bool is_corked() const
Definition: call.h:153
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:409
Status SendMessage(const M &message, WriteOptions options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:298
uint32_t flags() const
Returns raw flags bitset.
Definition: call.h:91
grpc_metadata * FillMetadataArray(const std::multimap< grpc::string, grpc::string > &metadata, size_t *metadata_count, const grpc::string &optional_error_details)
Definition: call.h:55
struct grpc_op::grpc_op_data::grpc_op_recv_initial_metadata recv_initial_metadata
A single metadata element.
Definition: grpc_types.h:432
Definition: call.h:266
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_receive_message_size)
Definition: call.h:677
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:235
void FinishOp(bool *status)
Definition: call.h:418
void * cq_tag() override
Get the tag to be used at the core completion queue.
Definition: call.h:653
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:536
virtual grpc_slice grpc_slice_from_static_buffer(const void *buffer, size_t length)=0
An Alarm posts the user provided tag to its associated completion queue upon expiry or cancellation...
Definition: alarm.h:31
Receive initial metadata: one and only one MUST be made on the client, must not be made on the server...
Definition: grpc_types.h:513
void RecvMessage(R *message)
Definition: call.h:396
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:480
#define GRPC_MUST_USE_RESULT
Definition: port_platform.h:473
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:494
WriteOptions(const WriteOptions &other)
Definition: call.h:84
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:451
CallOpClientRecvStatus()
Definition: call.h:541
Definition: byte_buffer.h:41
void SendInitialMetadata(const std::multimap< grpc::string, grpc::string > &metadata, uint32_t flags)
Definition: call.h:219
void FinishOp(bool *status)
Definition: call.h:458
Per-message write options.
Definition: call.h:81
void set_cq_tag(void *cq_tag)
set_cq_tag is used to provide a different core CQ tag than "this".
Definition: call.h:659
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:573
void AllowNoMessage()
Definition: call.h:329
size_t trailing_metadata_count
Definition: grpc_types.h:567
CallOpSendMessage()
Definition: call.h:268
grpc_metadata * metadata
Definition: grpc_types.h:550
void FinishOp(bool *status)
Definition: call.h:210
void FinishOp(bool *status)
Definition: call.h:343
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:95
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:597
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:627
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:468
virtual ~DeserializeFunc()
Definition: call.h:373
void RecvMessage(R *message)
Definition: call.h:326
int max_receive_message_size() const
Definition: call.h:691
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:651
CallOpSendInitialMetadata()
Definition: call.h:215
WriteOptions & set_corked()
corked bit: aliases set_buffer_hint currently, with the intent that set_buffer_hint will be removed i...
Definition: call.h:143
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:209
Did it work? If it didn&#39;t, why?
Definition: status.h:31
void FinishOp(bool *status)
Definition: call.h:290
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:523
grpc_metadata * initial_metadata_
Definition: call.h:259
DeserializeFuncType(R *message)
Definition: call.h:379
size_t initial_metadata_count_
Definition: call.h:258
grpc_status_code status
Definition: grpc_types.h:569
grpc_status_code * status
Definition: grpc_types.h:598
size_t count
Definition: grpc_types.h:549
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:684
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:540
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:185
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:517
A sequence of bytes.
Definition: byte_buffer.h:55
CallOpGenericRecvMessage()
Definition: call.h:392
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:334
CallOpSet()
Definition: call.h:626
const char kBinaryErrorDetailsKey[]
Definition: metadata_map.h:29
grpc::string error_details() const
Return the (binary) error details.
Definition: status.h:115
Straightforward wrapping of the C call object.
Definition: call.h:668
grpc_metadata * trailing_metadata
Definition: grpc_types.h:568
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:384