GRPC C++  1.4.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
call.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPCXX_IMPL_CODEGEN_CALL_H
35 #define GRPCXX_IMPL_CODEGEN_CALL_H
36 
37 #include <assert.h>
38 #include <cstring>
39 #include <functional>
40 #include <map>
41 #include <memory>
42 
52 
53 #include <grpc/impl/codegen/atm.h>
56 
57 struct grpc_byte_buffer;
58 
59 namespace grpc {
60 
61 class ByteBuffer;
62 class Call;
63 class CallHook;
66 
67 const char kBinaryErrorDetailsKey[] = "grpc-status-details-bin";
68 
69 // TODO(yangg) if the map is changed before we send, the pointers will be a
70 // mess. Make sure it does not happen.
72  const std::multimap<grpc::string, grpc::string>& metadata,
73  size_t* metadata_count, const grpc::string& optional_error_details) {
74  *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1);
75  if (*metadata_count == 0) {
76  return nullptr;
77  }
78  grpc_metadata* metadata_array =
80  (*metadata_count) * sizeof(grpc_metadata)));
81  size_t i = 0;
82  for (auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
83  metadata_array[i].key = SliceReferencingString(iter->first);
84  metadata_array[i].value = SliceReferencingString(iter->second);
85  }
86  if (!optional_error_details.empty()) {
87  metadata_array[i].key =
90  metadata_array[i].value = SliceReferencingString(optional_error_details);
91  }
92  return metadata_array;
93 }
94 
96 class WriteOptions {
97  public:
98  WriteOptions() : flags_(0), last_message_(false) {}
99  WriteOptions(const WriteOptions& other)
100  : flags_(other.flags_), last_message_(other.last_message_) {}
101 
103  inline void Clear() { flags_ = 0; }
104 
106  inline uint32_t flags() const { return flags_; }
107 
112  SetBit(GRPC_WRITE_NO_COMPRESS);
113  return *this;
114  }
115 
120  ClearBit(GRPC_WRITE_NO_COMPRESS);
121  return *this;
122  }
123 
128  inline bool get_no_compression() const {
129  return GetBit(GRPC_WRITE_NO_COMPRESS);
130  }
131 
137  SetBit(GRPC_WRITE_BUFFER_HINT);
138  return *this;
139  }
140 
146  ClearBit(GRPC_WRITE_BUFFER_HINT);
147  return *this;
148  }
149 
154  inline bool get_buffer_hint() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
155 
159  SetBit(GRPC_WRITE_BUFFER_HINT);
160  return *this;
161  }
162 
164  ClearBit(GRPC_WRITE_BUFFER_HINT);
165  return *this;
166  }
167 
168  inline bool is_corked() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
169 
176  last_message_ = true;
177  return *this;
178  }
179 
183  last_message_ = false;
184  return *this;
185  }
186 
191  bool is_last_message() const { return last_message_; }
192 
194  flags_ = rhs.flags_;
195  return *this;
196  }
197 
198  private:
199  void SetBit(const uint32_t mask) { flags_ |= mask; }
200 
201  void ClearBit(const uint32_t mask) { flags_ &= ~mask; }
202 
203  bool GetBit(const uint32_t mask) const { return (flags_ & mask) != 0; }
204 
205  uint32_t flags_;
206  bool last_message_;
207 };
208 
211 template <int I>
212 class CallNoOp {
213  protected:
214  void AddOp(grpc_op* ops, size_t* nops) {}
215  void FinishOp(bool* status) {}
216 };
217 
219  public:
221  maybe_compression_level_.is_set = false;
222  }
223 
225  const std::multimap<grpc::string, grpc::string>& metadata,
226  uint32_t flags) {
227  maybe_compression_level_.is_set = false;
228  send_ = true;
229  flags_ = flags;
232  }
233 
235  maybe_compression_level_.is_set = true;
237  }
238 
239  protected:
240  void AddOp(grpc_op* ops, size_t* nops) {
241  if (!send_) return;
242  grpc_op* op = &ops[(*nops)++];
244  op->flags = flags_;
245  op->reserved = NULL;
248  op->data.send_initial_metadata.maybe_compression_level.is_set =
250  if (maybe_compression_level_.is_set) {
251  op->data.send_initial_metadata.maybe_compression_level.level =
253  }
254  }
255  void FinishOp(bool* status) {
256  if (!send_) return;
258  send_ = false;
259  }
260 
261  bool send_;
262  uint32_t flags_;
265  struct {
266  bool is_set;
269 };
270 
272  public:
273  CallOpSendMessage() : send_buf_(nullptr), own_buf_(false) {}
274 
277  template <class M>
278  Status SendMessage(const M& message,
280 
281  template <class M>
282  Status SendMessage(const M& message) GRPC_MUST_USE_RESULT;
283 
284  protected:
285  void AddOp(grpc_op* ops, size_t* nops) {
286  if (send_buf_ == nullptr) return;
287  grpc_op* op = &ops[(*nops)++];
288  op->op = GRPC_OP_SEND_MESSAGE;
289  op->flags = write_options_.flags();
290  op->reserved = NULL;
291  op->data.send_message.send_message = send_buf_;
292  // Flags are per-message: clear them after use.
293  write_options_.Clear();
294  }
295  void FinishOp(bool* status) {
296  if (own_buf_) g_core_codegen_interface->grpc_byte_buffer_destroy(send_buf_);
297  send_buf_ = nullptr;
298  }
299 
300  private:
301  grpc_byte_buffer* send_buf_;
302  WriteOptions write_options_;
303  bool own_buf_;
304 };
305 
306 template <class M>
308  write_options_ = options;
309  return SerializationTraits<M>::Serialize(message, &send_buf_, &own_buf_);
310 }
311 
312 template <class M>
314  return SendMessage(message, WriteOptions());
315 }
316 
317 template <class R>
319  public:
321  : got_message(false),
322  message_(nullptr),
323  allow_not_getting_message_(false) {}
324 
325  void RecvMessage(R* message) { message_ = message; }
326 
327  // Do not change status if no message is received.
328  void AllowNoMessage() { allow_not_getting_message_ = true; }
329 
331 
332  protected:
333  void AddOp(grpc_op* ops, size_t* nops) {
334  if (message_ == nullptr) return;
335  grpc_op* op = &ops[(*nops)++];
336  op->op = GRPC_OP_RECV_MESSAGE;
337  op->flags = 0;
338  op->reserved = NULL;
339  op->data.recv_message.recv_message = &recv_buf_;
340  }
341 
342  void FinishOp(bool* status) {
343  if (message_ == nullptr) return;
344  if (recv_buf_) {
345  if (*status) {
346  got_message = *status =
347  SerializationTraits<R>::Deserialize(recv_buf_, message_).ok();
348  } else {
349  got_message = false;
351  }
352  } else {
353  got_message = false;
354  if (!allow_not_getting_message_) {
355  *status = false;
356  }
357  }
358  message_ = nullptr;
359  }
360 
361  private:
362  R* message_;
363  grpc_byte_buffer* recv_buf_;
364  bool allow_not_getting_message_;
365 };
366 
368  public:
370  : got_message(false), allow_not_getting_message_(false) {}
371 
372  template <class R>
373  void RecvMessage(R* message) {
374  deserialize_ = [message](grpc_byte_buffer* buf) -> Status {
375  return SerializationTraits<R>::Deserialize(buf, message);
376  };
377  }
378 
379  // Do not change status if no message is received.
380  void AllowNoMessage() { allow_not_getting_message_ = true; }
381 
383 
384  protected:
385  void AddOp(grpc_op* ops, size_t* nops) {
386  if (!deserialize_) return;
387  grpc_op* op = &ops[(*nops)++];
388  op->op = GRPC_OP_RECV_MESSAGE;
389  op->flags = 0;
390  op->reserved = NULL;
391  op->data.recv_message.recv_message = &recv_buf_;
392  }
393 
394  void FinishOp(bool* status) {
395  if (!deserialize_) return;
396  if (recv_buf_) {
397  if (*status) {
398  got_message = true;
399  *status = deserialize_(recv_buf_).ok();
400  } else {
401  got_message = false;
403  }
404  } else {
405  got_message = false;
406  if (!allow_not_getting_message_) {
407  *status = false;
408  }
409  }
410  deserialize_ = DeserializeFunc();
411  }
412 
413  private:
414  typedef std::function<Status(grpc_byte_buffer*)> DeserializeFunc;
415  DeserializeFunc deserialize_;
416  grpc_byte_buffer* recv_buf_;
417  bool allow_not_getting_message_;
418 };
419 
421  public:
422  CallOpClientSendClose() : send_(false) {}
423 
424  void ClientSendClose() { send_ = true; }
425 
426  protected:
427  void AddOp(grpc_op* ops, size_t* nops) {
428  if (!send_) return;
429  grpc_op* op = &ops[(*nops)++];
431  op->flags = 0;
432  op->reserved = NULL;
433  }
434  void FinishOp(bool* status) { send_ = false; }
435 
436  private:
437  bool send_;
438 };
439 
441  public:
442  CallOpServerSendStatus() : send_status_available_(false) {}
443 
445  const std::multimap<grpc::string, grpc::string>& trailing_metadata,
446  const Status& status) {
447  send_error_details_ = status.error_details();
448  trailing_metadata_ = FillMetadataArray(
449  trailing_metadata, &trailing_metadata_count_, send_error_details_);
450  send_status_available_ = true;
451  send_status_code_ = static_cast<grpc_status_code>(status.error_code());
452  send_error_message_ = status.error_message();
453  }
454 
455  protected:
456  void AddOp(grpc_op* ops, size_t* nops) {
457  if (!send_status_available_) return;
458  grpc_op* op = &ops[(*nops)++];
460  op->data.send_status_from_server.trailing_metadata_count =
461  trailing_metadata_count_;
462  op->data.send_status_from_server.trailing_metadata = trailing_metadata_;
463  op->data.send_status_from_server.status = send_status_code_;
464  error_message_slice_ = SliceReferencingString(send_error_message_);
465  op->data.send_status_from_server.status_details =
466  send_error_message_.empty() ? nullptr : &error_message_slice_;
467  op->flags = 0;
468  op->reserved = NULL;
469  }
470 
471  void FinishOp(bool* status) {
472  if (!send_status_available_) return;
473  g_core_codegen_interface->gpr_free(trailing_metadata_);
474  send_status_available_ = false;
475  }
476 
477  private:
478  bool send_status_available_;
479  grpc_status_code send_status_code_;
480  grpc::string send_error_details_;
481  grpc::string send_error_message_;
482  size_t trailing_metadata_count_;
483  grpc_metadata* trailing_metadata_;
484  grpc_slice error_message_slice_;
485 };
486 
488  public:
489  CallOpRecvInitialMetadata() : metadata_map_(nullptr) {}
490 
492  context->initial_metadata_received_ = true;
493  metadata_map_ = &context->recv_initial_metadata_;
494  }
495 
496  protected:
497  void AddOp(grpc_op* ops, size_t* nops) {
498  if (metadata_map_ == nullptr) return;
499  grpc_op* op = &ops[(*nops)++];
501  op->data.recv_initial_metadata.recv_initial_metadata = metadata_map_->arr();
502  op->flags = 0;
503  op->reserved = NULL;
504  }
505 
506  void FinishOp(bool* status) {
507  if (metadata_map_ == nullptr) return;
508  metadata_map_->FillMap();
509  metadata_map_ = nullptr;
510  }
511 
512  private:
513  MetadataMap* metadata_map_;
514 };
515 
517  public:
518  CallOpClientRecvStatus() : recv_status_(nullptr) {}
519 
520  void ClientRecvStatus(ClientContext* context, Status* status) {
521  metadata_map_ = &context->trailing_metadata_;
522  recv_status_ = status;
523  error_message_ = g_core_codegen_interface->grpc_empty_slice();
524  }
525 
526  protected:
527  void AddOp(grpc_op* ops, size_t* nops) {
528  if (recv_status_ == nullptr) return;
529  grpc_op* op = &ops[(*nops)++];
531  op->data.recv_status_on_client.trailing_metadata = metadata_map_->arr();
532  op->data.recv_status_on_client.status = &status_code_;
533  op->data.recv_status_on_client.status_details = &error_message_;
534  op->flags = 0;
535  op->reserved = NULL;
536  }
537 
538  void FinishOp(bool* status) {
539  if (recv_status_ == nullptr) return;
540  metadata_map_->FillMap();
541  grpc::string binary_error_details;
542  auto iter = metadata_map_->map()->find(kBinaryErrorDetailsKey);
543  if (iter != metadata_map_->map()->end()) {
544  binary_error_details =
545  grpc::string(iter->second.begin(), iter->second.length());
546  }
547  *recv_status_ = Status(static_cast<StatusCode>(status_code_),
548  grpc::string(GRPC_SLICE_START_PTR(error_message_),
549  GRPC_SLICE_END_PTR(error_message_)),
550  binary_error_details);
552  recv_status_ = nullptr;
553  }
554 
555  private:
556  MetadataMap* metadata_map_;
557  Status* recv_status_;
558  grpc_status_code status_code_;
559  grpc_slice error_message_;
560 };
561 
568  public:
571  virtual void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) = 0;
572 };
573 
580 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
581  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
582  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
584  public Op1,
585  public Op2,
586  public Op3,
587  public Op4,
588  public Op5,
589  public Op6 {
590  public:
591  CallOpSet() : return_tag_(this) {}
592  void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) override {
593  this->Op1::AddOp(ops, nops);
594  this->Op2::AddOp(ops, nops);
595  this->Op3::AddOp(ops, nops);
596  this->Op4::AddOp(ops, nops);
597  this->Op5::AddOp(ops, nops);
598  this->Op6::AddOp(ops, nops);
600  call_ = call;
601  }
602 
603  bool FinalizeResult(void** tag, bool* status) override {
604  this->Op1::FinishOp(status);
605  this->Op2::FinishOp(status);
606  this->Op3::FinishOp(status);
607  this->Op4::FinishOp(status);
608  this->Op5::FinishOp(status);
609  this->Op6::FinishOp(status);
610  *tag = return_tag_;
612  return true;
613  }
614 
615  void set_output_tag(void* return_tag) { return_tag_ = return_tag; }
616 
617  private:
618  void* return_tag_;
619  grpc_call* call_;
620 };
621 
626 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
627  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
628  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
629 class SneakyCallOpSet : public CallOpSet<Op1, Op2, Op3, Op4, Op5, Op6> {
630  public:
631  bool FinalizeResult(void** tag, bool* status) override {
633  return Base::FinalizeResult(tag, status) && false;
634  }
635 };
636 
638 class Call final {
639  public:
642  : call_hook_(call_hook),
643  cq_(cq),
644  call_(call),
645  max_receive_message_size_(-1) {}
646 
649  : call_hook_(call_hook),
650  cq_(cq),
651  call_(call),
652  max_receive_message_size_(max_receive_message_size) {}
653 
655  call_hook_->PerformOpsOnCall(ops, this);
656  }
657 
658  grpc_call* call() const { return call_; }
659  CompletionQueue* cq() const { return cq_; }
660 
661  int max_receive_message_size() const { return max_receive_message_size_; }
662 
663  private:
664  CallHook* call_hook_;
665  CompletionQueue* cq_;
666  grpc_call* call_;
667  int max_receive_message_size_;
668 };
669 
670 } // namespace grpc
671 
672 #endif // GRPCXX_IMPL_CODEGEN_CALL_H
void ServerSendStatus(const std::multimap< grpc::string, grpc::string > &trailing_metadata, const Status &status)
Definition: call.h:444
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:86
CallOpRecvInitialMetadata()
Definition: call.h:489
grpc_op_type op
Operation type, as defined by grpc_op_type.
Definition: grpc_types.h:490
void RecvMessage(R *message)
Definition: call.h:373
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq, int max_receive_message_size)
Definition: call.h:647
bool is_corked() const
Definition: call.h:168
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:145
Default argument for CallOpSet.
Definition: call.h:212
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:427
CallOpServerSendStatus()
Definition: call.h:442
void FinishOp(bool *status)
Definition: call.h:215
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:136
virtual void grpc_call_ref(grpc_call *call)=0
grpc_metadata_array * recv_initial_metadata
Definition: grpc_types.h:528
grpc::string error_message() const
Return the instance's error message.
Definition: status.h:70
CallOpSendMessage()
Definition: call.h:273
std::string string
Definition: config.h:50
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:385
union grpc_op::@12 data
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call.h:119
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:455
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call.h:567
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:460
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:175
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:358
grpc_metadata_array * arr()
Definition: metadata_map.h:62
void AllowNoMessage()
Definition: call.h:328
grpc_slice key
the key, value values are expected to line up with grpc_mdelem: if changing them, update metadata...
Definition: grpc_types.h:387
void FinishOp(bool *status)
Definition: call.h:394
Definition: call.h:516
grpc_slice value
Definition: grpc_types.h:388
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:333
void Clear()
Clear all flags.
Definition: call.h:103
grpc_compression_level level
Definition: call.h:267
virtual grpc_slice grpc_empty_slice()=0
#define GRPC_MUST_USE_RESULT
Definition: port_platform.h:390
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. ...
Definition: slice.h:91
#define GRPC_WRITE_BUFFER_HINT
Write Flags:
Definition: grpc_types.h:355
const char kBinaryErrorDetailsKey[]
Definition: call.h:67
Call(grpc_call *call, CallHook *call_hook, CompletionQueue *cq)
call is owned by the caller
Definition: call.h:641
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:450
virtual void grpc_call_unref(grpc_call *call)=0
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:456
WriteOptions & clear_last_messsage()
Clears flag indicating that this is the last message in a stream, disabling coalescing.
Definition: call.h:182
Definition: metadata_map.h:41
WriteOptions()
Definition: call.h:98
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:631
struct grpc_op::@12::@19 recv_status_on_client
Definition: grpc_types.h:56
grpc_slice SliceReferencingString(const grpc::string &str)
Definition: slice.h:53
Definition: call.h:440
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:83
uint32_t flags() const
Returns raw flags bitset.
Definition: call.h:106
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:127
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:240
void FillMap()
Definition: metadata_map.h:49
WriteOptions & clear_corked()
Definition: call.h:163
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call.h:111
#define GRPC_SLICE_END_PTR(slice)
Definition: slice.h:136
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:168
WriteOptions & operator=(const WriteOptions &rhs)
Definition: call.h:193
virtual void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)=0
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:64
void SendInitialMetadata(const std::multimap< grpc::string, grpc::string > &metadata, uint32_t flags)
Definition: call.h:224
Definition: call.h:271
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:603
void FinishOp(bool *status)
Definition: call.h:471
bool send_
Definition: call.h:261
CallOpClientRecvStatus()
Definition: call.h:518
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call.h:128
struct grpc_byte_buffer * send_message
Definition: grpc_types.h:511
void FinishOp(bool *status)
Definition: call.h:434
CallOpSet()
Definition: call.h:591
Definition: call.h:420
Status SendMessage(const M &message, WriteOptions options) GRPC_MUST_USE_RESULT
Send message using options for the write.
Definition: call.h:307
bool is_set
Definition: call.h:266
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:534
CallOpSendInitialMetadata()
Definition: call.h:220
void AllowNoMessage()
Definition: call.h:380
CompletionQueue * cq() const
Definition: call.h:659
int max_receive_message_size() const
Definition: call.h:661
A single metadata element.
Definition: grpc_types.h:384
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:527
Straightforward wrapping of the C call object.
Definition: call.h:638
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments) ...
Definition: grpc_types.h:488
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:465
std::multimap< grpc::string_ref, grpc::string_ref > * map()
Definition: metadata_map.h:58
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:214
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:64
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:446
WriteOptions(const WriteOptions &other)
Definition: call.h:99
Primary implementaiton of CallOpSetInterface.
Definition: call.h:583
struct grpc_op::@12::@14 send_initial_metadata
void ClientSendClose()
Definition: call.h:424
Definition: call.h:318
Per-message write options.
Definition: call.h:96
CallOpClientSendClose()
Definition: call.h:422
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:154
virtual void FillOps(grpc_call *call, grpc_op *ops, size_t *nops)=0
Fills in grpc_op, starting from ops[*nops] and moving upwards.
void FinishOp(bool *status)
Definition: call.h:342
CallOpRecvMessage()
Definition: call.h:320
StatusCode error_code() const
Return the instance's error code.
Definition: status.h:68
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:101
virtual void PerformOpsOnCall(CallOpSetInterface *ops, Call *call)=0
void FinishOp(bool *status)
Definition: call.h:295
struct grpc_op::@12::@16 send_status_from_server
virtual void grpc_slice_unref(grpc_slice slice)=0
void FinishOp(bool *status)
Definition: call.h:506
bool got_message
Definition: call.h:330
grpc::string error_details() const
Return the (binary) error details.
Definition: status.h:73
void ClientRecvStatus(ClientContext *context, Status *status)
Definition: call.h:520
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:56
void PerformOps(CallOpSetInterface *ops)
Definition: call.h:654
WriteOptions & set_corked()
corked bit: aliases set_buffer_hint currently, with the intent that set_buffer_hint will be removed i...
Definition: call.h:158
Did it work? If it didn't, why?
Definition: status.h:45
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:475
Definition: call.h:218
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:497
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:492
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:592
grpc_metadata * FillMetadataArray(const std::multimap< grpc::string, grpc::string > &metadata, size_t *metadata_count, const grpc::string &optional_error_details)
Definition: call.h:71
struct grpc::CallOpSendInitialMetadata::@0 maybe_compression_level_
grpc_call * call() const
Definition: call.h:658
void RecvMessage(R *message)
Definition: call.h:325
void * reserved
Reserved for future usage.
Definition: grpc_types.h:494
CallOpGenericRecvMessage()
Definition: call.h:369
virtual void gpr_free(void *p)=0
void set_compression_level(grpc_compression_level level)
Definition: call.h:234
bool got_message
Definition: call.h:382
A CallOpSet that does not post completions to the completion queue.
Definition: call.h:629
void FinishOp(bool *status)
Definition: call.h:538
uint32_t flags_
Definition: call.h:262
void set_output_tag(void *return_tag)
Definition: call.h:615
size_t initial_metadata_count_
Definition: call.h:263
Receive a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:469
This is an interface that Channel and Server implement to allow them to hook performing ops...
Definition: call_hook.h:44
void RecvInitialMetadata(ClientContext *context)
Definition: call.h:491
Definition: call.h:487
void AddOp(grpc_op *ops, size_t *nops)
Definition: call.h:285
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:191
grpc_metadata * initial_metadata_
Definition: call.h:264
Definition: call.h:367
virtual void * gpr_malloc(size_t size)=0
void FinishOp(bool *status)
Definition: call.h:255