GRPC C++  1.13.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 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 =
65  (grpc_metadata*)(g_core_codegen_interface->gpr_malloc(
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 =
74  g_core_codegen_interface->grpc_slice_from_static_buffer(
75  kBinaryErrorDetailsKey, sizeof(kBinaryErrorDetailsKey) - 1);
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:
217  CallOpSendInitialMetadata() : send_(false) {
218  maybe_compression_level_.is_set = false;
219  }
220 
222  const std::multimap<grpc::string, grpc::string>& metadata,
223  uint32_t flags) {
224  maybe_compression_level_.is_set = false;
225  send_ = true;
226  flags_ = flags;
227  initial_metadata_ =
228  FillMetadataArray(metadata, &initial_metadata_count_, "");
229  }
230 
232  maybe_compression_level_.is_set = true;
233  maybe_compression_level_.level = level;
234  }
235 
236  protected:
237  void AddOp(grpc_op* ops, size_t* nops) {
238  if (!send_) return;
239  grpc_op* op = &ops[(*nops)++];
241  op->flags = flags_;
242  op->reserved = NULL;
243  op->data.send_initial_metadata.count = initial_metadata_count_;
244  op->data.send_initial_metadata.metadata = initial_metadata_;
246  maybe_compression_level_.is_set;
247  if (maybe_compression_level_.is_set) {
249  maybe_compression_level_.level;
250  }
251  }
252  void FinishOp(bool* status) {
253  if (!send_) return;
254  g_core_codegen_interface->gpr_free(initial_metadata_);
255  send_ = false;
256  }
257 
258  bool send_;
259  uint32_t flags_;
262  struct {
263  bool is_set;
265  } maybe_compression_level_;
266 };
267 
269  public:
270  CallOpSendMessage() : send_buf_() {}
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_.Valid()) 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_.c_buffer();
289  // Flags are per-message: clear them after use.
290  write_options_.Clear();
291  }
292  void FinishOp(bool* status) { send_buf_.Clear(); }
293 
294  private:
295  ByteBuffer send_buf_;
296  WriteOptions write_options_;
297 };
298 
299 template <class M>
301  write_options_ = options;
302  bool own_buf;
303  // TODO(vjpai): Remove the void below when possible
304  // The void in the template parameter below should not be needed
305  // (since it should be implicit) but is needed due to an observed
306  // difference in behavior between clang and gcc for certain internal users
308  message, send_buf_.bbuf_ptr(), &own_buf);
309  if (!own_buf) {
310  send_buf_.Duplicate();
311  }
312  return result;
313 }
314 
315 template <class M>
317  return SendMessage(message, WriteOptions());
318 }
319 
320 template <class R>
321 class CallOpRecvMessage {
322  public:
324  : got_message(false),
325  message_(nullptr),
326  allow_not_getting_message_(false) {}
327 
328  void RecvMessage(R* message) { message_ = message; }
329 
330  // Do not change status if no message is received.
331  void AllowNoMessage() { allow_not_getting_message_ = true; }
332 
334 
335  protected:
336  void AddOp(grpc_op* ops, size_t* nops) {
337  if (message_ == nullptr) return;
338  grpc_op* op = &ops[(*nops)++];
339  op->op = GRPC_OP_RECV_MESSAGE;
340  op->flags = 0;
341  op->reserved = NULL;
342  op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr();
343  }
344 
345  void FinishOp(bool* status) {
346  if (message_ == nullptr) return;
347  if (recv_buf_.Valid()) {
348  if (*status) {
349  got_message = *status =
350  SerializationTraits<R>::Deserialize(recv_buf_.bbuf_ptr(), message_)
351  .ok();
352  recv_buf_.Release();
353  } else {
354  got_message = false;
355  recv_buf_.Clear();
356  }
357  } else {
358  got_message = false;
359  if (!allow_not_getting_message_) {
360  *status = false;
361  }
362  }
363  message_ = nullptr;
364  }
365 
366  private:
367  R* message_;
368  ByteBuffer recv_buf_;
369  bool allow_not_getting_message_;
370 };
371 
373  public:
374  virtual Status Deserialize(ByteBuffer* buf) = 0;
375  virtual ~DeserializeFunc() {}
376 };
377 
378 template <class R>
379 class DeserializeFuncType final : public DeserializeFunc {
380  public:
381  DeserializeFuncType(R* message) : message_(message) {}
382  Status Deserialize(ByteBuffer* buf) override {
383  return SerializationTraits<R>::Deserialize(buf->bbuf_ptr(), message_);
384  }
385 
386  ~DeserializeFuncType() override {}
387 
388  private:
389  R* message_; // Not a managed pointer because management is external to this
390 };
391 
393  public:
395  : got_message(false), allow_not_getting_message_(false) {}
396 
397  template <class R>
398  void RecvMessage(R* message) {
399  // Use an explicit base class pointer to avoid resolution error in the
400  // following unique_ptr::reset for some old implementations.
401  DeserializeFunc* func = new DeserializeFuncType<R>(message);
402  deserialize_.reset(func);
403  }
404 
405  // Do not change status if no message is received.
406  void AllowNoMessage() { allow_not_getting_message_ = true; }
407 
409 
410  protected:
411  void AddOp(grpc_op* ops, size_t* nops) {
412  if (!deserialize_) return;
413  grpc_op* op = &ops[(*nops)++];
414  op->op = GRPC_OP_RECV_MESSAGE;
415  op->flags = 0;
416  op->reserved = NULL;
417  op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr();
418  }
419 
420  void FinishOp(bool* status) {
421  if (!deserialize_) return;
422  if (recv_buf_.Valid()) {
423  if (*status) {
424  got_message = true;
425  *status = deserialize_->Deserialize(&recv_buf_).ok();
426  recv_buf_.Release();
427  } else {
428  got_message = false;
429  recv_buf_.Clear();
430  }
431  } else {
432  got_message = false;
433  if (!allow_not_getting_message_) {
434  *status = false;
435  }
436  }
437  deserialize_.reset();
438  }
439 
440  private:
441  std::unique_ptr<DeserializeFunc> deserialize_;
442  ByteBuffer recv_buf_;
443  bool allow_not_getting_message_;
444 };
445 
447  public:
448  CallOpClientSendClose() : send_(false) {}
449 
450  void ClientSendClose() { send_ = true; }
451 
452  protected:
453  void AddOp(grpc_op* ops, size_t* nops) {
454  if (!send_) return;
455  grpc_op* op = &ops[(*nops)++];
457  op->flags = 0;
458  op->reserved = NULL;
459  }
460  void FinishOp(bool* status) { send_ = false; }
461 
462  private:
463  bool send_;
464 };
465 
467  public:
468  CallOpServerSendStatus() : send_status_available_(false) {}
469 
471  const std::multimap<grpc::string, grpc::string>& trailing_metadata,
472  const Status& status) {
473  send_error_details_ = status.error_details();
474  trailing_metadata_ = FillMetadataArray(
475  trailing_metadata, &trailing_metadata_count_, send_error_details_);
476  send_status_available_ = true;
477  send_status_code_ = static_cast<grpc_status_code>(status.error_code());
478  send_error_message_ = status.error_message();
479  }
480 
481  protected:
482  void AddOp(grpc_op* ops, size_t* nops) {
483  if (!send_status_available_) return;
484  grpc_op* op = &ops[(*nops)++];
487  trailing_metadata_count_;
488  op->data.send_status_from_server.trailing_metadata = trailing_metadata_;
489  op->data.send_status_from_server.status = send_status_code_;
490  error_message_slice_ = SliceReferencingString(send_error_message_);
492  send_error_message_.empty() ? nullptr : &error_message_slice_;
493  op->flags = 0;
494  op->reserved = NULL;
495  }
496 
497  void FinishOp(bool* status) {
498  if (!send_status_available_) return;
499  g_core_codegen_interface->gpr_free(trailing_metadata_);
500  send_status_available_ = false;
501  }
502 
503  private:
504  bool send_status_available_;
505  grpc_status_code send_status_code_;
506  grpc::string send_error_details_;
507  grpc::string send_error_message_;
508  size_t trailing_metadata_count_;
509  grpc_metadata* trailing_metadata_;
510  grpc_slice error_message_slice_;
511 };
512 
514  public:
515  CallOpRecvInitialMetadata() : metadata_map_(nullptr) {}
516 
518  context->initial_metadata_received_ = true;
519  metadata_map_ = &context->recv_initial_metadata_;
520  }
521 
522  protected:
523  void AddOp(grpc_op* ops, size_t* nops) {
524  if (metadata_map_ == nullptr) return;
525  grpc_op* op = &ops[(*nops)++];
527  op->data.recv_initial_metadata.recv_initial_metadata = metadata_map_->arr();
528  op->flags = 0;
529  op->reserved = NULL;
530  }
531 
532  void FinishOp(bool* status) {
533  if (metadata_map_ == nullptr) return;
534  metadata_map_->FillMap();
535  metadata_map_ = nullptr;
536  }
537 
538  private:
539  MetadataMap* metadata_map_;
540 };
541 
543  public:
545  : recv_status_(nullptr), debug_error_string_(nullptr) {}
546 
547  void ClientRecvStatus(ClientContext* context, Status* status) {
548  client_context_ = context;
549  metadata_map_ = &client_context_->trailing_metadata_;
550  recv_status_ = status;
551  error_message_ = g_core_codegen_interface->grpc_empty_slice();
552  }
553 
554  protected:
555  void AddOp(grpc_op* ops, size_t* nops) {
556  if (recv_status_ == nullptr) return;
557  grpc_op* op = &ops[(*nops)++];
559  op->data.recv_status_on_client.trailing_metadata = metadata_map_->arr();
560  op->data.recv_status_on_client.status = &status_code_;
561  op->data.recv_status_on_client.status_details = &error_message_;
562  op->data.recv_status_on_client.error_string = &debug_error_string_;
563  op->flags = 0;
564  op->reserved = NULL;
565  }
566 
567  void FinishOp(bool* status) {
568  if (recv_status_ == nullptr) return;
569  metadata_map_->FillMap();
570  grpc::string binary_error_details;
571  auto iter = metadata_map_->map()->find(kBinaryErrorDetailsKey);
572  if (iter != metadata_map_->map()->end()) {
573  binary_error_details =
574  grpc::string(iter->second.begin(), iter->second.length());
575  }
576  *recv_status_ = Status(static_cast<StatusCode>(status_code_),
577  grpc::string(GRPC_SLICE_START_PTR(error_message_),
578  GRPC_SLICE_END_PTR(error_message_)),
579  binary_error_details);
580  client_context_->set_debug_error_string(
581  debug_error_string_ != nullptr ? debug_error_string_ : "");
582  g_core_codegen_interface->grpc_slice_unref(error_message_);
583  if (debug_error_string_ != nullptr) {
584  g_core_codegen_interface->gpr_free((void*)debug_error_string_);
585  }
586  recv_status_ = nullptr;
587  }
588 
589  private:
590  ClientContext* client_context_;
591  MetadataMap* metadata_map_;
592  Status* recv_status_;
593  const char* debug_error_string_;
594  grpc_status_code status_code_;
595  grpc_slice error_message_;
596 };
597 
604  public:
607  virtual void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) = 0;
608 };
609 
616 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
617  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
618  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
620  public Op1,
621  public Op2,
622  public Op3,
623  public Op4,
624  public Op5,
625  public Op6 {
626  public:
627  CallOpSet() : return_tag_(this), call_(nullptr) {}
628  void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) override {
629  this->Op1::AddOp(ops, nops);
630  this->Op2::AddOp(ops, nops);
631  this->Op3::AddOp(ops, nops);
632  this->Op4::AddOp(ops, nops);
633  this->Op5::AddOp(ops, nops);
634  this->Op6::AddOp(ops, nops);
635  g_core_codegen_interface->grpc_call_ref(call);
636  call_ = call;
637  }
638 
639  bool FinalizeResult(void** tag, bool* status) override {
640  this->Op1::FinishOp(status);
641  this->Op2::FinishOp(status);
642  this->Op3::FinishOp(status);
643  this->Op4::FinishOp(status);
644  this->Op5::FinishOp(status);
645  this->Op6::FinishOp(status);
646  *tag = return_tag_;
647 
648  g_core_codegen_interface->grpc_call_unref(call_);
649  return true;
650  }
651 
652  void set_output_tag(void* return_tag) { return_tag_ = return_tag; }
653 
654  private:
655  void* return_tag_;
656  grpc_call* call_;
657 };
658 
660 class Call final {
661  public:
663  Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq)
664  : call_hook_(call_hook),
665  cq_(cq),
666  call_(call),
667  max_receive_message_size_(-1) {}
668 
669  Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq,
670  int max_receive_message_size)
671  : call_hook_(call_hook),
672  cq_(cq),
673  call_(call),
674  max_receive_message_size_(max_receive_message_size) {}
675 
677  call_hook_->PerformOpsOnCall(ops, this);
678  }
679 
680  grpc_call* call() const { return call_; }
681  CompletionQueue* cq() const { return cq_; }
682 
683  int max_receive_message_size() const { return max_receive_message_size_; }
684 
685  private:
686  CallHook* call_hook_;
687  CompletionQueue* cq_;
688  grpc_call* call_;
689  int max_receive_message_size_;
690 };
691 } // namespace internal
692 } // namespace grpc
693 
694 #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:529
grpc_metadata_array * recv_initial_metadata
Definition: grpc_types.h:572
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:115
void * reserved
Reserved for future usage.
Definition: grpc_types.h:533
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:497
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:523
void ClientSendClose()
Definition: call.h:450
virtual void grpc_call_ref(grpc_call *call)=0
CallOpRecvMessage()
Definition: call.h:323
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:141
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:580
void FinishOp(bool *status)
Definition: call.h:532
struct grpc_byte_buffer * send_message
This op takes ownership of the slices in send_message.
Definition: grpc_types.h:555
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:494
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:499
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:282
void AllowNoMessage()
Definition: call.h:406
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:394
grpc_slice key
the key, value values are expected to line up with grpc_mdelem: if changing them, update metadata...
Definition: grpc_types.h:426
Status Deserialize(ByteBuffer *buf) override
Definition: call.h:382
CallOpRecvInitialMetadata()
Definition: call.h:515
struct grpc_op::grpc_op_data::grpc_op_recv_message recv_message
Primary implementation of CallOpSetInterface.
Definition: call.h:619
grpc_slice value
Definition: grpc_types.h:427
#define GRPC_WRITE_THROUGH
Force this message to be written to the socket before completing it.
Definition: grpc_types.h:396
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:594
grpc_slice * status_details
Definition: grpc_types.h:590
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:258
#define GRPC_WRITE_BUFFER_HINT
Write Flags:
Definition: grpc_types.h:391
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
call is owned by the caller
Definition: call.h:663
void RecvInitialMetadata(ClientContext *context)
Definition: call.h:517
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:489
bool got_message
Definition: call.h:333
virtual void grpc_call_unref(grpc_call *call)=0
CompletionQueue * cq() const
Definition: call.h:681
bool is_write_through() const
Definition: call.h:181
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: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:547
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:680
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:116
bool is_set
Definition: call.h:263
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:588
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:448
void FinishOp(bool *status)
Definition: call.h:252
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:555
Definition: byte_buffer.h:49
uint32_t flags_
Definition: call.h:259
Default argument for CallOpSet.
Definition: call.h:209
void FinishOp(bool *status)
Definition: call.h:567
grpc_compression_level level
Definition: call.h:264
bool got_message
Definition: call.h:408
grpc::string error_message() const
Return the instance&#39;s error message.
Definition: status.h:112
Definition: call.h:372
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:468
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:639
void set_compression_level(grpc_compression_level level)
Definition: call.h:231
bool is_corked() const
Definition: call.h:155
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:411
Status SendMessage(const M &message, WriteOptions options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:300
uint32_t flags() const
Returns raw flags bitset.
Definition: call.h:93
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:423
Definition: call.h:268
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_receive_message_size)
Definition: call.h:669
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:237
void FinishOp(bool *status)
Definition: call.h:420
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:527
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:504
void RecvMessage(R *message)
Definition: call.h:398
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:482
#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:485
WriteOptions(const WriteOptions &other)
Definition: call.h:86
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:453
CallOpClientRecvStatus()
Definition: call.h:544
Definition: byte_buffer.h:41
void SendInitialMetadata(const std::multimap< grpc::string, grpc::string > &metadata, uint32_t flags)
Definition: call.h:221
void FinishOp(bool *status)
Definition: call.h:460
Per-message write options.
Definition: call.h:83
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:564
void AllowNoMessage()
Definition: call.h:331
size_t trailing_metadata_count
Definition: grpc_types.h:558
CallOpSendMessage()
Definition: call.h:270
grpc_metadata * metadata
Definition: grpc_types.h:541
void FinishOp(bool *status)
Definition: call.h:212
void FinishOp(bool *status)
Definition: call.h:345
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:94
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:603
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:628
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:470
virtual ~DeserializeFunc()
Definition: call.h:375
void RecvMessage(R *message)
Definition: call.h:328
int max_receive_message_size() const
Definition: call.h:683
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:652
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
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:211
Did it work? If it didn&#39;t, why?
Definition: status.h:31
void FinishOp(bool *status)
Definition: call.h:292
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:514
grpc_metadata * initial_metadata_
Definition: call.h:261
DeserializeFuncType(R *message)
Definition: call.h:381
size_t initial_metadata_count_
Definition: call.h:260
grpc_status_code status
Definition: grpc_types.h:560
grpc_status_code * status
Definition: grpc_types.h:589
size_t count
Definition: grpc_types.h:540
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:676
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:531
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
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:508
A sequence of bytes.
Definition: byte_buffer.h:53
CallOpGenericRecvMessage()
Definition: call.h:394
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:336
CallOpSet()
Definition: call.h:627
const char kBinaryErrorDetailsKey[]
Definition: call.h:53
grpc::string error_details() const
Return the (binary) error details.
Definition: status.h:115
Straightforward wrapping of the C call object.
Definition: call.h:660
grpc_metadata * trailing_metadata
Definition: grpc_types.h:559
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:386