GRPC C++  1.64.0
call_op_set.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2018 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_CALL_OP_SET_H
20 #define GRPCPP_IMPL_CALL_OP_SET_H
21 
22 #include <cstring>
23 #include <map>
24 #include <memory>
25 
26 #include "absl/log/check.h"
27 
28 #include <grpc/grpc.h>
30 #include <grpc/impl/grpc_types.h>
31 #include <grpc/slice.h>
32 #include <grpc/support/alloc.h>
33 #include <grpc/support/log.h>
34 #include <grpcpp/client_context.h>
36 #include <grpcpp/impl/call.h>
37 #include <grpcpp/impl/call_hook.h>
44 #include <grpcpp/support/config.h>
45 #include <grpcpp/support/slice.h>
47 
48 namespace grpc {
49 
50 namespace internal {
51 class Call;
52 class CallHook;
53 
54 // TODO(yangg) if the map is changed before we send, the pointers will be a
55 // mess. Make sure it does not happen.
57  const std::multimap<std::string, std::string>& metadata,
58  size_t* metadata_count, const std::string& optional_error_details) {
59  *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1);
60  if (*metadata_count == 0) {
61  return nullptr;
62  }
63  grpc_metadata* metadata_array = static_cast<grpc_metadata*>(
64  gpr_malloc((*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 = grpc_slice_from_static_buffer(
73  metadata_array[i].value = SliceReferencingString(optional_error_details);
74  }
75  return metadata_array;
76 }
77 } // namespace internal
78 
80 class WriteOptions {
81  public:
82  WriteOptions() : flags_(0), last_message_(false) {}
83 
85  inline void Clear() { flags_ = 0; }
86 
88  inline uint32_t flags() const { return flags_; }
89 
94  SetBit(GRPC_WRITE_NO_COMPRESS);
95  return *this;
96  }
97 
102  ClearBit(GRPC_WRITE_NO_COMPRESS);
103  return *this;
104  }
105 
110  inline bool get_no_compression() const {
111  return GetBit(GRPC_WRITE_NO_COMPRESS);
112  }
113 
119  SetBit(GRPC_WRITE_BUFFER_HINT);
120  return *this;
121  }
122 
128  ClearBit(GRPC_WRITE_BUFFER_HINT);
129  return *this;
130  }
131 
136  inline bool get_buffer_hint() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
137 
141  SetBit(GRPC_WRITE_BUFFER_HINT);
142  return *this;
143  }
144 
146  ClearBit(GRPC_WRITE_BUFFER_HINT);
147  return *this;
148  }
149 
150  inline bool is_corked() const { return GetBit(GRPC_WRITE_BUFFER_HINT); }
151 
158  last_message_ = true;
159  return *this;
160  }
161 
165  last_message_ = false;
166  return *this;
167  }
168 
173  bool is_last_message() const { return last_message_; }
174 
178  SetBit(GRPC_WRITE_THROUGH);
179  return *this;
180  }
181 
183  ClearBit(GRPC_WRITE_THROUGH);
184  return *this;
185  }
186 
187  inline bool is_write_through() const { return GetBit(GRPC_WRITE_THROUGH); }
188 
189  private:
190  void SetBit(const uint32_t mask) { flags_ |= mask; }
191 
192  void ClearBit(const uint32_t mask) { flags_ &= ~mask; }
193 
194  bool GetBit(const uint32_t mask) const { return (flags_ & mask) != 0; }
195 
196  uint32_t flags_;
197  bool last_message_;
198 };
199 
200 namespace internal {
201 
205 template <int Unused>
206 class CallNoOp {
207  protected:
208  void AddOp(grpc_op* /*ops*/, size_t* /*nops*/) {}
209  void FinishOp(bool* /*status*/) {}
211  InterceptorBatchMethodsImpl* /*interceptor_methods*/) {}
213  InterceptorBatchMethodsImpl* /*interceptor_methods*/) {}
214  void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) {
215  }
216 };
217 
219  public:
221  maybe_compression_level_.is_set = false;
222  }
223 
224  void SendInitialMetadata(std::multimap<std::string, std::string>* metadata,
225  uint32_t flags) {
226  maybe_compression_level_.is_set = false;
227  send_ = true;
228  flags_ = flags;
229  metadata_map_ = metadata;
230  }
231 
233  maybe_compression_level_.is_set = true;
235  }
236 
237  protected:
238  void AddOp(grpc_op* ops, size_t* nops) {
239  if (!send_ || hijacked_) return;
240  grpc_op* op = &ops[(*nops)++];
242  op->flags = flags_;
243  op->reserved = nullptr;
250  if (maybe_compression_level_.is_set) {
253  }
254  }
255  void FinishOp(bool* /*status*/) {
256  if (!send_ || hijacked_) return;
258  send_ = false;
259  }
260 
262  InterceptorBatchMethodsImpl* interceptor_methods) {
263  if (!send_) return;
264  interceptor_methods->AddInterceptionHookPoint(
266  interceptor_methods->SetSendInitialMetadata(metadata_map_);
267  }
268 
270  InterceptorBatchMethodsImpl* /*interceptor_methods*/) {}
271 
272  void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) {
273  hijacked_ = true;
274  }
275 
276  bool hijacked_ = false;
277  bool send_;
278  uint32_t flags_;
280  std::multimap<std::string, std::string>* metadata_map_;
282  struct {
283  bool is_set;
286 };
287 
289  public:
290  CallOpSendMessage() : send_buf_() {}
291 
294  template <class M>
295  GRPC_MUST_USE_RESULT Status SendMessage(const M& message,
296  WriteOptions options);
297 
298  template <class M>
299  GRPC_MUST_USE_RESULT Status SendMessage(const M& message);
300 
304  template <class M>
305  GRPC_MUST_USE_RESULT Status SendMessagePtr(const M* message,
306  WriteOptions options);
307 
310  template <class M>
311  GRPC_MUST_USE_RESULT Status SendMessagePtr(const M* message);
312 
313  protected:
314  void AddOp(grpc_op* ops, size_t* nops) {
315  if (msg_ == nullptr && !send_buf_.Valid()) return;
316  if (hijacked_) {
317  serializer_ = nullptr;
318  return;
319  }
320  if (msg_ != nullptr) {
321  CHECK(serializer_(msg_).ok());
322  }
323  serializer_ = nullptr;
324  grpc_op* op = &ops[(*nops)++];
325  op->op = GRPC_OP_SEND_MESSAGE;
326  op->flags = write_options_.flags();
327  op->reserved = nullptr;
328  op->data.send_message.send_message = send_buf_.c_buffer();
329  // Flags are per-message: clear them after use.
330  write_options_.Clear();
331  }
332  void FinishOp(bool* status) {
333  if (msg_ == nullptr && !send_buf_.Valid()) return;
334  send_buf_.Clear();
335  if (hijacked_ && failed_send_) {
336  // Hijacking interceptor failed this Op
337  *status = false;
338  } else if (!*status) {
339  // This Op was passed down to core and the Op failed
340  failed_send_ = true;
341  }
342  }
343 
345  InterceptorBatchMethodsImpl* interceptor_methods) {
346  if (msg_ == nullptr && !send_buf_.Valid()) return;
347  interceptor_methods->AddInterceptionHookPoint(
349  interceptor_methods->SetSendMessage(&send_buf_, &msg_, &failed_send_,
350  serializer_);
351  }
352 
354  InterceptorBatchMethodsImpl* interceptor_methods) {
355  if (msg_ != nullptr || send_buf_.Valid()) {
356  interceptor_methods->AddInterceptionHookPoint(
358  }
359  send_buf_.Clear();
360  msg_ = nullptr;
361  // The contents of the SendMessage value that was previously set
362  // has had its references stolen by core's operations
363  interceptor_methods->SetSendMessage(nullptr, nullptr, &failed_send_,
364  nullptr);
365  }
366 
367  void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) {
368  hijacked_ = true;
369  }
370 
371  private:
372  const void* msg_ = nullptr; // The original non-serialized message
373  bool hijacked_ = false;
374  bool failed_send_ = false;
375  ByteBuffer send_buf_;
376  WriteOptions write_options_;
377  std::function<Status(const void*)> serializer_;
378 };
379 
380 template <class M>
382  write_options_ = options;
383  // Serialize immediately since we do not have access to the message pointer
384  bool own_buf;
386  message, send_buf_.bbuf_ptr(), &own_buf);
387  if (!own_buf) {
388  send_buf_.Duplicate();
389  }
390  return result;
391 }
392 
393 template <class M>
395  return SendMessage(message, WriteOptions());
396 }
397 
398 template <class M>
400  WriteOptions options) {
401  msg_ = message;
402  write_options_ = options;
403  // Store the serializer for later since we have access to the message
404  serializer_ = [this](const void* message) {
405  bool own_buf;
406  // TODO(vjpai): Remove the void below when possible
407  // The void in the template parameter below should not be needed
408  // (since it should be implicit) but is needed due to an observed
409  // difference in behavior between clang and gcc for certain internal users
411  *static_cast<const M*>(message), send_buf_.bbuf_ptr(), &own_buf);
412  if (!own_buf) {
413  send_buf_.Duplicate();
414  }
415  return result;
416  };
417  return Status();
418 }
419 
420 template <class M>
422  return SendMessagePtr(message, WriteOptions());
423 }
424 
425 template <class R>
427  public:
428  void RecvMessage(R* message) { message_ = message; }
429 
430  // Do not change status if no message is received.
431  void AllowNoMessage() { allow_not_getting_message_ = true; }
432 
433  bool got_message = false;
434 
435  protected:
436  void AddOp(grpc_op* ops, size_t* nops) {
437  if (message_ == nullptr || hijacked_) return;
438  grpc_op* op = &ops[(*nops)++];
439  op->op = GRPC_OP_RECV_MESSAGE;
440  op->flags = 0;
441  op->reserved = nullptr;
442  op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr();
443  }
444 
445  void FinishOp(bool* status) {
446  if (message_ == nullptr) return;
447  if (recv_buf_.Valid()) {
448  if (*status) {
449  got_message = *status =
450  SerializationTraits<R>::Deserialize(recv_buf_.bbuf_ptr(), message_)
451  .ok();
452  recv_buf_.Release();
453  } else {
454  got_message = false;
455  recv_buf_.Clear();
456  }
457  } else if (hijacked_) {
458  if (hijacked_recv_message_failed_) {
459  FinishOpRecvMessageFailureHandler(status);
460  } else {
461  // The op was hijacked and it was successful. There is no further action
462  // to be performed since the message is already in its non-serialized
463  // form.
464  }
465  } else {
466  FinishOpRecvMessageFailureHandler(status);
467  }
468  }
469 
471  InterceptorBatchMethodsImpl* interceptor_methods) {
472  if (message_ == nullptr) return;
473  interceptor_methods->SetRecvMessage(message_,
474  &hijacked_recv_message_failed_);
475  }
476 
478  InterceptorBatchMethodsImpl* interceptor_methods) {
479  if (message_ == nullptr) return;
480  interceptor_methods->AddInterceptionHookPoint(
482  if (!got_message) interceptor_methods->SetRecvMessage(nullptr, nullptr);
483  }
484  void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
485  hijacked_ = true;
486  if (message_ == nullptr) return;
487  interceptor_methods->AddInterceptionHookPoint(
489  got_message = true;
490  }
491 
492  private:
493  // Sets got_message and \a status for a failed recv message op
494  void FinishOpRecvMessageFailureHandler(bool* status) {
495  got_message = false;
496  if (!allow_not_getting_message_) {
497  *status = false;
498  }
499  }
500 
501  R* message_ = nullptr;
502  ByteBuffer recv_buf_;
503  bool allow_not_getting_message_ = false;
504  bool hijacked_ = false;
505  bool hijacked_recv_message_failed_ = false;
506 };
507 
509  public:
510  virtual Status Deserialize(ByteBuffer* buf) = 0;
511  virtual ~DeserializeFunc() {}
512 };
513 
514 template <class R>
515 class DeserializeFuncType final : public DeserializeFunc {
516  public:
517  explicit DeserializeFuncType(R* message) : message_(message) {}
518  Status Deserialize(ByteBuffer* buf) override {
519  return SerializationTraits<R>::Deserialize(buf->bbuf_ptr(), message_);
520  }
521 
522  ~DeserializeFuncType() override {}
523 
524  private:
525  R* message_; // Not a managed pointer because management is external to this
526 };
527 
529  public:
530  template <class R>
531  void RecvMessage(R* message) {
532  // Use an explicit base class pointer to avoid resolution error in the
533  // following unique_ptr::reset for some old implementations.
534  DeserializeFunc* func = new DeserializeFuncType<R>(message);
535  deserialize_.reset(func);
536  message_ = message;
537  }
538 
539  // Do not change status if no message is received.
540  void AllowNoMessage() { allow_not_getting_message_ = true; }
541 
542  bool got_message = false;
543 
544  protected:
545  void AddOp(grpc_op* ops, size_t* nops) {
546  if (!deserialize_ || hijacked_) return;
547  grpc_op* op = &ops[(*nops)++];
548  op->op = GRPC_OP_RECV_MESSAGE;
549  op->flags = 0;
550  op->reserved = nullptr;
551  op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr();
552  }
553 
554  void FinishOp(bool* status) {
555  if (!deserialize_) return;
556  if (recv_buf_.Valid()) {
557  if (*status) {
558  got_message = true;
559  *status = deserialize_->Deserialize(&recv_buf_).ok();
560  recv_buf_.Release();
561  } else {
562  got_message = false;
563  recv_buf_.Clear();
564  }
565  } else if (hijacked_) {
566  if (hijacked_recv_message_failed_) {
567  FinishOpRecvMessageFailureHandler(status);
568  } else {
569  // The op was hijacked and it was successful. There is no further action
570  // to be performed since the message is already in its non-serialized
571  // form.
572  }
573  } else {
574  got_message = false;
575  if (!allow_not_getting_message_) {
576  *status = false;
577  }
578  }
579  }
580 
582  InterceptorBatchMethodsImpl* interceptor_methods) {
583  if (!deserialize_) return;
584  interceptor_methods->SetRecvMessage(message_,
585  &hijacked_recv_message_failed_);
586  }
587 
589  InterceptorBatchMethodsImpl* interceptor_methods) {
590  if (!deserialize_) return;
591  interceptor_methods->AddInterceptionHookPoint(
593  if (!got_message) interceptor_methods->SetRecvMessage(nullptr, nullptr);
594  deserialize_.reset();
595  }
596  void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
597  hijacked_ = true;
598  if (!deserialize_) return;
599  interceptor_methods->AddInterceptionHookPoint(
601  got_message = true;
602  }
603 
604  private:
605  // Sets got_message and \a status for a failed recv message op
606  void FinishOpRecvMessageFailureHandler(bool* status) {
607  got_message = false;
608  if (!allow_not_getting_message_) {
609  *status = false;
610  }
611  }
612 
613  void* message_ = nullptr;
614  std::unique_ptr<DeserializeFunc> deserialize_;
615  ByteBuffer recv_buf_;
616  bool allow_not_getting_message_ = false;
617  bool hijacked_ = false;
618  bool hijacked_recv_message_failed_ = false;
619 };
620 
622  public:
623  CallOpClientSendClose() : send_(false) {}
624 
625  void ClientSendClose() { send_ = true; }
626 
627  protected:
628  void AddOp(grpc_op* ops, size_t* nops) {
629  if (!send_ || hijacked_) return;
630  grpc_op* op = &ops[(*nops)++];
632  op->flags = 0;
633  op->reserved = nullptr;
634  }
635  void FinishOp(bool* /*status*/) { send_ = false; }
636 
638  InterceptorBatchMethodsImpl* interceptor_methods) {
639  if (!send_) return;
640  interceptor_methods->AddInterceptionHookPoint(
642  }
643 
645  InterceptorBatchMethodsImpl* /*interceptor_methods*/) {}
646 
647  void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) {
648  hijacked_ = true;
649  }
650 
651  private:
652  bool hijacked_ = false;
653  bool send_;
654 };
655 
657  public:
658  CallOpServerSendStatus() : send_status_available_(false) {}
659 
661  std::multimap<std::string, std::string>* trailing_metadata,
662  const Status& status) {
663  send_error_details_ = status.error_details();
664  metadata_map_ = trailing_metadata;
665  send_status_available_ = true;
666  send_status_code_ = static_cast<grpc_status_code>(status.error_code());
667  send_error_message_ = status.error_message();
668  }
669 
670  protected:
671  void AddOp(grpc_op* ops, size_t* nops) {
672  if (!send_status_available_ || hijacked_) return;
673  trailing_metadata_ = FillMetadataArray(
674  *metadata_map_, &trailing_metadata_count_, send_error_details_);
675  grpc_op* op = &ops[(*nops)++];
678  trailing_metadata_count_;
679  op->data.send_status_from_server.trailing_metadata = trailing_metadata_;
680  op->data.send_status_from_server.status = send_status_code_;
681  error_message_slice_ = SliceReferencingString(send_error_message_);
683  send_error_message_.empty() ? nullptr : &error_message_slice_;
684  op->flags = 0;
685  op->reserved = nullptr;
686  }
687 
688  void FinishOp(bool* /*status*/) {
689  if (!send_status_available_ || hijacked_) return;
690  gpr_free(trailing_metadata_);
691  send_status_available_ = false;
692  }
693 
695  InterceptorBatchMethodsImpl* interceptor_methods) {
696  if (!send_status_available_) return;
697  interceptor_methods->AddInterceptionHookPoint(
699  interceptor_methods->SetSendTrailingMetadata(metadata_map_);
700  interceptor_methods->SetSendStatus(&send_status_code_, &send_error_details_,
701  &send_error_message_);
702  }
703 
705  InterceptorBatchMethodsImpl* /*interceptor_methods*/) {}
706 
707  void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) {
708  hijacked_ = true;
709  }
710 
711  private:
712  bool hijacked_ = false;
713  bool send_status_available_;
714  grpc_status_code send_status_code_;
715  std::string send_error_details_;
716  std::string send_error_message_;
717  size_t trailing_metadata_count_;
718  std::multimap<std::string, std::string>* metadata_map_;
719  grpc_metadata* trailing_metadata_;
720  grpc_slice error_message_slice_;
721 };
722 
724  public:
725  CallOpRecvInitialMetadata() : metadata_map_(nullptr) {}
726 
728  context->initial_metadata_received_ = true;
729  metadata_map_ = &context->recv_initial_metadata_;
730  }
731 
732  protected:
733  void AddOp(grpc_op* ops, size_t* nops) {
734  if (metadata_map_ == nullptr || hijacked_) return;
735  grpc_op* op = &ops[(*nops)++];
737  op->data.recv_initial_metadata.recv_initial_metadata = metadata_map_->arr();
738  op->flags = 0;
739  op->reserved = nullptr;
740  }
741 
742  void FinishOp(bool* /*status*/) {
743  if (metadata_map_ == nullptr || hijacked_) return;
744  }
745 
747  InterceptorBatchMethodsImpl* interceptor_methods) {
748  interceptor_methods->SetRecvInitialMetadata(metadata_map_);
749  }
750 
752  InterceptorBatchMethodsImpl* interceptor_methods) {
753  if (metadata_map_ == nullptr) return;
754  interceptor_methods->AddInterceptionHookPoint(
756  metadata_map_ = nullptr;
757  }
758 
759  void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
760  hijacked_ = true;
761  if (metadata_map_ == nullptr) return;
762  interceptor_methods->AddInterceptionHookPoint(
764  }
765 
766  private:
767  bool hijacked_ = false;
768  MetadataMap* metadata_map_;
769 };
770 
772  public:
774  : recv_status_(nullptr), debug_error_string_(nullptr) {}
775 
776  void ClientRecvStatus(grpc::ClientContext* context, Status* status) {
777  client_context_ = context;
778  metadata_map_ = &client_context_->trailing_metadata_;
779  recv_status_ = status;
780  error_message_ = grpc_empty_slice();
781  }
782 
783  protected:
784  void AddOp(grpc_op* ops, size_t* nops) {
785  if (recv_status_ == nullptr || hijacked_) return;
786  grpc_op* op = &ops[(*nops)++];
788  op->data.recv_status_on_client.trailing_metadata = metadata_map_->arr();
789  op->data.recv_status_on_client.status = &status_code_;
790  op->data.recv_status_on_client.status_details = &error_message_;
791  op->data.recv_status_on_client.error_string = &debug_error_string_;
792  op->flags = 0;
793  op->reserved = nullptr;
794  }
795 
796  void FinishOp(bool* /*status*/) {
797  if (recv_status_ == nullptr || hijacked_) return;
798  if (static_cast<StatusCode>(status_code_) == StatusCode::OK) {
799  *recv_status_ = Status();
800  DCHECK_EQ(debug_error_string_, nullptr);
801  } else {
802  *recv_status_ =
803  Status(static_cast<StatusCode>(status_code_),
804  GRPC_SLICE_IS_EMPTY(error_message_)
805  ? std::string()
806  : std::string(GRPC_SLICE_START_PTR(error_message_),
807  GRPC_SLICE_END_PTR(error_message_)),
808  metadata_map_->GetBinaryErrorDetails());
809  if (debug_error_string_ != nullptr) {
810  client_context_->set_debug_error_string(debug_error_string_);
811  gpr_free(const_cast<char*>(debug_error_string_));
812  }
813  }
814  // TODO(soheil): Find callers that set debug string even for status OK,
815  // and fix them.
816  grpc_slice_unref(error_message_);
817  }
818 
820  InterceptorBatchMethodsImpl* interceptor_methods) {
821  interceptor_methods->SetRecvStatus(recv_status_);
822  interceptor_methods->SetRecvTrailingMetadata(metadata_map_);
823  }
824 
826  InterceptorBatchMethodsImpl* interceptor_methods) {
827  if (recv_status_ == nullptr) return;
828  interceptor_methods->AddInterceptionHookPoint(
830  recv_status_ = nullptr;
831  }
832 
833  void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
834  hijacked_ = true;
835  if (recv_status_ == nullptr) return;
836  interceptor_methods->AddInterceptionHookPoint(
838  }
839 
840  private:
841  bool hijacked_ = false;
842  grpc::ClientContext* client_context_;
843  MetadataMap* metadata_map_;
844  Status* recv_status_;
845  const char* debug_error_string_;
846  grpc_status_code status_code_;
847  grpc_slice error_message_;
848 };
849 
850 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
851  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
852  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
853 class CallOpSet;
854 
861 template <class Op1, class Op2, class Op3, class Op4, class Op5, class Op6>
862 class CallOpSet : public CallOpSetInterface,
863  public Op1,
864  public Op2,
865  public Op3,
866  public Op4,
867  public Op5,
868  public Op6 {
869  public:
870  CallOpSet() : core_cq_tag_(this), return_tag_(this) {}
871  // The copy constructor and assignment operator reset the value of
872  // core_cq_tag_, return_tag_, done_intercepting_ and interceptor_methods_
873  // since those are only meaningful on a specific object, not across objects.
874  CallOpSet(const CallOpSet& other)
875  : core_cq_tag_(this),
876  return_tag_(this),
877  call_(other.call_),
878  done_intercepting_(false),
879  interceptor_methods_(InterceptorBatchMethodsImpl()) {}
880 
881  CallOpSet& operator=(const CallOpSet& other) {
882  if (&other == this) {
883  return *this;
884  }
885  core_cq_tag_ = this;
886  return_tag_ = this;
887  call_ = other.call_;
888  done_intercepting_ = false;
889  interceptor_methods_ = InterceptorBatchMethodsImpl();
890  return *this;
891  }
892 
893  void FillOps(Call* call) override {
894  done_intercepting_ = false;
895  grpc_call_ref(call->call());
896  call_ =
897  *call; // It's fine to create a copy of call since it's just pointers
898 
899  if (RunInterceptors()) {
901  } else {
902  // After the interceptors are run, ContinueFillOpsAfterInterception will
903  // be run
904  }
905  }
906 
907  bool FinalizeResult(void** tag, bool* status) override {
908  if (done_intercepting_) {
909  // Complete the avalanching since we are done with this batch of ops
910  call_.cq()->CompleteAvalanching();
911  // We have already finished intercepting and filling in the results. This
912  // round trip from the core needed to be made because interceptors were
913  // run
914  *tag = return_tag_;
915  *status = saved_status_;
916  grpc_call_unref(call_.call());
917  return true;
918  }
919 
920  this->Op1::FinishOp(status);
921  this->Op2::FinishOp(status);
922  this->Op3::FinishOp(status);
923  this->Op4::FinishOp(status);
924  this->Op5::FinishOp(status);
925  this->Op6::FinishOp(status);
926  saved_status_ = *status;
927  if (RunInterceptorsPostRecv()) {
928  *tag = return_tag_;
929  grpc_call_unref(call_.call());
930  return true;
931  }
932  // Interceptors are going to be run, so we can't return the tag just yet.
933  // After the interceptors are run, ContinueFinalizeResultAfterInterception
934  return false;
935  }
936 
937  void set_output_tag(void* return_tag) { return_tag_ = return_tag; }
938 
939  void* core_cq_tag() override { return core_cq_tag_; }
940 
945  void set_core_cq_tag(void* core_cq_tag) { core_cq_tag_ = core_cq_tag; }
946 
947  // This will be called while interceptors are run if the RPC is a hijacked
948  // RPC. This should set hijacking state for each of the ops.
949  void SetHijackingState() override {
950  this->Op1::SetHijackingState(&interceptor_methods_);
951  this->Op2::SetHijackingState(&interceptor_methods_);
952  this->Op3::SetHijackingState(&interceptor_methods_);
953  this->Op4::SetHijackingState(&interceptor_methods_);
954  this->Op5::SetHijackingState(&interceptor_methods_);
955  this->Op6::SetHijackingState(&interceptor_methods_);
956  }
957 
958  // Should be called after interceptors are done running
960  static const size_t MAX_OPS = 6;
961  grpc_op ops[MAX_OPS];
962  size_t nops = 0;
963  this->Op1::AddOp(ops, &nops);
964  this->Op2::AddOp(ops, &nops);
965  this->Op3::AddOp(ops, &nops);
966  this->Op4::AddOp(ops, &nops);
967  this->Op5::AddOp(ops, &nops);
968  this->Op6::AddOp(ops, &nops);
969 
970  grpc_call_error err =
971  grpc_call_start_batch(call_.call(), ops, nops, core_cq_tag(), nullptr);
972 
973  if (err != GRPC_CALL_OK) {
974  // A failure here indicates an API misuse; for example, doing a Write
975  // while another Write is already pending on the same RPC or invoking
976  // WritesDone multiple times
977  gpr_log(GPR_ERROR, "API misuse of type %s observed",
979  CHECK(false);
980  }
981  }
982 
983  // Should be called after interceptors are done running on the finalize result
984  // path
986  done_intercepting_ = true;
987  // The following call_start_batch is internally-generated so no need for an
988  // explanatory log on failure.
989  CHECK(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag(),
990  nullptr) == GRPC_CALL_OK);
991  }
992 
993  private:
994  // Returns true if no interceptors need to be run
995  bool RunInterceptors() {
996  interceptor_methods_.ClearState();
997  interceptor_methods_.SetCallOpSetInterface(this);
998  interceptor_methods_.SetCall(&call_);
999  this->Op1::SetInterceptionHookPoint(&interceptor_methods_);
1000  this->Op2::SetInterceptionHookPoint(&interceptor_methods_);
1001  this->Op3::SetInterceptionHookPoint(&interceptor_methods_);
1002  this->Op4::SetInterceptionHookPoint(&interceptor_methods_);
1003  this->Op5::SetInterceptionHookPoint(&interceptor_methods_);
1004  this->Op6::SetInterceptionHookPoint(&interceptor_methods_);
1005  if (interceptor_methods_.InterceptorsListEmpty()) {
1006  return true;
1007  }
1008  // This call will go through interceptors and would need to
1009  // schedule new batches, so delay completion queue shutdown
1010  call_.cq()->RegisterAvalanching();
1011  return interceptor_methods_.RunInterceptors();
1012  }
1013  // Returns true if no interceptors need to be run
1014  bool RunInterceptorsPostRecv() {
1015  // Call and OpSet had already been set on the set state.
1016  // SetReverse also clears previously set hook points
1017  interceptor_methods_.SetReverse();
1018  this->Op1::SetFinishInterceptionHookPoint(&interceptor_methods_);
1019  this->Op2::SetFinishInterceptionHookPoint(&interceptor_methods_);
1020  this->Op3::SetFinishInterceptionHookPoint(&interceptor_methods_);
1021  this->Op4::SetFinishInterceptionHookPoint(&interceptor_methods_);
1022  this->Op5::SetFinishInterceptionHookPoint(&interceptor_methods_);
1023  this->Op6::SetFinishInterceptionHookPoint(&interceptor_methods_);
1024  return interceptor_methods_.RunInterceptors();
1025  }
1026 
1027  void* core_cq_tag_;
1028  void* return_tag_;
1029  Call call_;
1030  bool done_intercepting_ = false;
1031  InterceptorBatchMethodsImpl interceptor_methods_;
1032  bool saved_status_;
1033 };
1034 
1035 } // namespace internal
1036 } // namespace grpc
1037 
1038 #endif // GRPCPP_IMPL_CALL_OP_SET_H
grpc::internal::CallOpSendMessage::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:367
gpr_malloc
GPRAPI void * gpr_malloc(size_t size)
malloc.
grpc::internal::Call::cq
grpc::CompletionQueue * cq() const
Definition: call.h:71
grpc::internal::CallOpRecvInitialMetadata
Definition: call_op_set.h:723
grpc_op::grpc_op_data::grpc_op_send_message::send_message
struct grpc_byte_buffer * send_message
This op takes ownership of the slices in send_message.
Definition: grpc_types.h:339
grpc_op::flags
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:315
grpc::internal::CallOpSendInitialMetadata::initial_metadata_
grpc_metadata * initial_metadata_
Definition: call_op_set.h:281
grpc::internal::CallOpRecvMessage::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:477
grpc_empty_slice
GPRAPI grpc_slice grpc_empty_slice(void)
grpc_call_error
grpc_call_error
Result of a grpc call.
Definition: grpc_types.h:140
grpc::WriteOptions::clear_last_message
WriteOptions & clear_last_message()
Clears flag indicating that this is the last message in a stream, disabling coalescing.
Definition: call_op_set.h:164
grpc::WriteOptions::set_corked
WriteOptions & set_corked()
corked bit: aliases set_buffer_hint currently, with the intent that set_buffer_hint will be removed i...
Definition: call_op_set.h:140
grpc::experimental::InterceptionHookPoints::POST_RECV_STATUS
@ POST_RECV_STATUS
grpc::WriteOptions::get_buffer_hint
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_op_set.h:136
grpc::internal::CallOpClientRecvStatus::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:784
grpc_op::grpc_op_data::grpc_op_recv_status_on_client::trailing_metadata
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:372
grpc::internal::CallOpClientSendClose
Definition: call_op_set.h:621
grpc::internal::CallOpSendInitialMetadata::maybe_compression_level_
struct grpc::internal::CallOpSendInitialMetadata::@3 maybe_compression_level_
grpc_op::grpc_op_data::grpc_op_recv_status_on_client::status
grpc_status_code * status
Definition: grpc_types.h:373
grpc::experimental::InterceptionHookPoints::PRE_SEND_CLOSE
@ PRE_SEND_CLOSE
grpc::internal::CallOpRecvMessage::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:484
grpc::internal::CallOpClientSendClose::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:647
grpc::internal::CallOpSet::CallOpSet
CallOpSet()
Definition: call_op_set.h:870
grpc::internal::CallOpSendInitialMetadata::flags_
uint32_t flags_
Definition: call_op_set.h:278
grpc::internal::CallOpGenericRecvMessage
Definition: call_op_set.h:528
grpc::internal::CallOpRecvInitialMetadata::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:759
grpc::internal::CallOpServerSendStatus
Definition: call_op_set.h:656
GRPC_SLICE_START_PTR
#define GRPC_SLICE_START_PTR(slice)
Definition: slice_type.h:99
grpc::ByteBuffer::Duplicate
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:140
grpc::internal::CallOpSendInitialMetadata::hijacked_
bool hijacked_
Definition: call_op_set.h:276
grpc::experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA
@ PRE_SEND_INITIAL_METADATA
The first three in this list are for clients and servers.
grpc::internal::CallOpGenericRecvMessage::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:545
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc::internal::CallOpSet
Primary implementation of CallOpSetInterface.
Definition: completion_queue.h:98
grpc::internal::CallOpSendInitialMetadata::metadata_map_
std::multimap< std::string, std::string > * metadata_map_
Definition: call_op_set.h:280
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::grpc_op_send_initial_metadata_maybe_compression_level::level
grpc_compression_level level
Definition: grpc_types.h:330
grpc::internal::CallOpSendMessage
Definition: call_op_set.h:288
GRPC_SLICE_END_PTR
#define GRPC_SLICE_END_PTR(slice)
Definition: slice_type.h:108
interceptor_common.h
grpc_op::grpc_op_data::send_initial_metadata
struct grpc_op::grpc_op_data::grpc_op_send_initial_metadata send_initial_metadata
grpc::WriteOptions::get_no_compression
bool get_no_compression() const
Get value for the flag indicating whether compression for the next message write is forcefully disabl...
Definition: call_op_set.h:110
grpc_status_code
grpc_status_code
Definition: status.h:28
grpc::internal::InterceptorBatchMethodsImpl::SetRecvInitialMetadata
void SetRecvInitialMetadata(MetadataMap *map)
Definition: interceptor_common.h:174
grpc::WriteOptions::set_last_message
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call_op_set.h:157
GRPC_MUST_USE_RESULT
#define GRPC_MUST_USE_RESULT
Definition: port_platform.h:656
grpc::experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA
@ POST_RECV_INITIAL_METADATA
The following two are for all clients and servers.
grpc::experimental::InterceptionHookPoints::POST_RECV_MESSAGE
@ POST_RECV_MESSAGE
grpc::internal::CallOpSendMessage::FinishOp
void FinishOp(bool *status)
Definition: call_op_set.h:332
grpc_op::reserved
void * reserved
Reserved for future usage.
Definition: grpc_types.h:317
grpc::internal::InterceptorBatchMethodsImpl::SetCallOpSetInterface
void SetCallOpSetInterface(CallOpSetInterface *ops)
Definition: interceptor_common.h:220
grpc::internal::CallOpGenericRecvMessage::RecvMessage
void RecvMessage(R *message)
Definition: call_op_set.h:531
grpc::experimental::InterceptionHookPoints::PRE_RECV_MESSAGE
@ PRE_RECV_MESSAGE
GPR_ERROR
#define GPR_ERROR
Definition: log.h:55
grpc::WriteOptions::is_write_through
bool is_write_through() const
Definition: call_op_set.h:187
grpc::experimental::InterceptionHookPoints::PRE_RECV_STATUS
@ PRE_RECV_STATUS
grpc::internal::CallOpSet::FillOps
void FillOps(Call *call) override
Definition: call_op_set.h:893
intercepted_channel.h
grpc::internal::InterceptorBatchMethodsImpl::SetCall
void SetCall(Call *call)
Definition: interceptor_common.h:216
grpc::internal::InterceptorBatchMethodsImpl::InterceptorsListEmpty
bool InterceptorsListEmpty()
Definition: interceptor_common.h:224
grpc::internal::CallOpClientRecvStatus::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:833
grpc::internal::InterceptorBatchMethodsImpl::ClearState
void ClearState()
Definition: interceptor_common.h:202
grpc::internal::CallOpSendMessage::CallOpSendMessage
CallOpSendMessage()
Definition: call_op_set.h:290
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:36
grpc::internal::MetadataMap::arr
grpc_metadata_array * arr()
Definition: metadata_map.h:71
GRPC_CALL_OK
@ GRPC_CALL_OK
everything went ok
Definition: grpc_types.h:142
grpc::WriteOptions::WriteOptions
WriteOptions()
Definition: call_op_set.h:82
grpc::WriteOptions::set_write_through
WriteOptions & set_write_through()
Guarantee that all bytes have been written to the socket before completing this write (usually writes...
Definition: call_op_set.h:177
grpc::internal::CallOpClientRecvStatus::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:825
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:218
completion_queue_tag.h
grpc::internal::CallOpSendInitialMetadata::initial_metadata_count_
size_t initial_metadata_count_
Definition: call_op_set.h:279
grpc::internal::CallOpClientSendClose::FinishOp
void FinishOp(bool *)
Definition: call_op_set.h:635
grpc::internal::CallOpServerSendStatus::ServerSendStatus
void ServerSendStatus(std::multimap< std::string, std::string > *trailing_metadata, const Status &status)
Definition: call_op_set.h:660
grpc::internal::CallOpClientRecvStatus::CallOpClientRecvStatus
CallOpClientRecvStatus()
Definition: call_op_set.h:773
grpc::internal::CallNoOp::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:210
grpc_call_ref
GRPCAPI void grpc_call_ref(grpc_call *call)
Ref a call.
GRPC_WRITE_NO_COMPRESS
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:189
grpc::internal::CallNoOp::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:214
grpc::internal::CallOpRecvMessage::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:470
grpc_op::grpc_op_data::recv_message
struct grpc_op::grpc_op_data::grpc_op_recv_message recv_message
grpc::internal::MetadataMap
Definition: metadata_map.h:34
grpc::internal::CallOpServerSendStatus::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:671
grpc::experimental::InterceptionHookPoints::PRE_SEND_STATUS
@ PRE_SEND_STATUS
grpc_op::data
union grpc_op::grpc_op_data data
grpc::internal::CallNoOp::FinishOp
void FinishOp(bool *)
Definition: call_op_set.h:209
grpc::internal::CallOpSendInitialMetadata::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:269
grpc::internal::CallOpRecvMessage::FinishOp
void FinishOp(bool *status)
Definition: call_op_set.h:445
grpc_types.h
grpc::internal::CallOpSet::CallOpSet
CallOpSet(const CallOpSet &other)
Definition: call_op_set.h:874
grpc::WriteOptions::flags
uint32_t flags() const
Returns raw flags bitset.
Definition: call_op_set.h:88
gpr_free
GPRAPI void gpr_free(void *ptr)
free
grpc::internal::CallNoOp::AddOp
void AddOp(grpc_op *, size_t *)
Definition: call_op_set.h:208
grpc::internal::CallOpServerSendStatus::CallOpServerSendStatus
CallOpServerSendStatus()
Definition: call_op_set.h:658
grpc::internal::CallOpSet::ContinueFillOpsAfterInterception
void ContinueFillOpsAfterInterception() override
Definition: call_op_set.h:959
grpc_op::grpc_op_data::grpc_op_recv_message::recv_message
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:364
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:34
grpc::internal::DeserializeFunc
Definition: call_op_set.h:508
grpc_metadata
A single metadata element.
Definition: grpc_types.h:210
grpc::internal::CallOpSendInitialMetadata::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:272
grpc::internal::CallOpSendMessage::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:314
grpc::internal::InterceptorBatchMethodsImpl::SetSendStatus
void SetSendStatus(grpc_status_code *code, std::string *error_details, std::string *error_message)
Definition: interceptor_common.h:157
grpc::internal::CallOpSet::core_cq_tag
void * core_cq_tag() override
Definition: call_op_set.h:939
grpc::internal::CallOpRecvInitialMetadata::CallOpRecvInitialMetadata
CallOpRecvInitialMetadata()
Definition: call_op_set.h:725
grpc::internal::CallOpGenericRecvMessage::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:596
GRPC_OP_RECV_INITIAL_METADATA
@ GRPC_OP_RECV_INITIAL_METADATA
Receive initial metadata: one and only one MUST be made on the client, must not be made on the server...
Definition: grpc_types.h:288
grpc::internal::CallOpRecvMessage::got_message
bool got_message
Definition: call_op_set.h:433
grpc::internal::CallOpSendMessage::SendMessage
GRPC_MUST_USE_RESULT Status SendMessage(const M &message, WriteOptions options)
Send message using options for the write.
GRPC_OP_SEND_STATUS_FROM_SERVER
@ GRPC_OP_SEND_STATUS_FROM_SERVER
Send status from the server: one and only one instance MUST be sent from the server unless the call w...
Definition: grpc_types.h:283
grpc::internal::CallOpRecvInitialMetadata::RecvInitialMetadata
void RecvInitialMetadata(grpc::ClientContext *context)
Definition: call_op_set.h:727
grpc::internal::CallOpClientRecvStatus::ClientRecvStatus
void ClientRecvStatus(grpc::ClientContext *context, Status *status)
Definition: call_op_set.h:776
log.h
GRPC_SLICE_IS_EMPTY
#define GRPC_SLICE_IS_EMPTY(slice)
Definition: slice_type.h:110
grpc::OK
@ OK
Not an error; returned on success.
Definition: status_code_enum.h:28
grpc::internal::kBinaryErrorDetailsKey
const char kBinaryErrorDetailsKey[]
Definition: metadata_map.h:32
grpc_call_unref
GRPCAPI void grpc_call_unref(grpc_call *call)
Unref a call.
grpc_op::grpc_op_data::grpc_op_send_status_from_server::status
grpc_status_code status
Definition: grpc_types.h:344
grpc_op::grpc_op_data::grpc_op_recv_status_on_client::error_string
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:378
completion_queue.h
grpc::WriteOptions::clear_write_through
WriteOptions & clear_write_through()
Definition: call_op_set.h:182
grpc::ClientContext
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:195
grpc::internal::CallOpGenericRecvMessage::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:588
grpc::WriteOptions::is_corked
bool is_corked() const
Definition: call_op_set.h:150
grpc::ByteBuffer::Clear
void Clear()
Remove all data.
Definition: byte_buffer.h:128
grpc_metadata::value
grpc_slice value
Definition: grpc_types.h:214
grpc.h
grpc::internal::DeserializeFuncType
Definition: call_op_set.h:515
grpc::ByteBuffer
A sequence of bytes.
Definition: byte_buffer.h:60
grpc::internal::CallOpSendMessage::SendMessagePtr
GRPC_MUST_USE_RESULT Status SendMessagePtr(const M *message, WriteOptions options)
Send message using options for the write.
GRPC_WRITE_BUFFER_HINT
#define GRPC_WRITE_BUFFER_HINT
Write Flags:
Definition: grpc_types.h:186
grpc::internal::CallOpClientRecvStatus::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:819
grpc::internal::DeserializeFunc::~DeserializeFunc
virtual ~DeserializeFunc()
Definition: call_op_set.h:511
grpc_op
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments)
Definition: grpc_types.h:311
grpc::internal::InterceptorBatchMethodsImpl::SetReverse
void SetReverse()
Definition: interceptor_common.h:209
GRPC_OP_SEND_MESSAGE
@ GRPC_OP_SEND_MESSAGE
Send a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:273
grpc::internal::InterceptorBatchMethodsImpl::SetRecvStatus
void SetRecvStatus(Status *status)
Definition: interceptor_common.h:178
grpc::internal::CallOpClientSendClose::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:637
grpc::internal::CallOpSet::SetHijackingState
void SetHijackingState() override
Definition: call_op_set.h:949
grpc::internal::CallOpSendInitialMetadata::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:238
GRPC_WRITE_THROUGH
#define GRPC_WRITE_THROUGH
Force this message to be written to the socket before completing it.
Definition: grpc_types.h:191
grpc_op::grpc_op_data::grpc_op_send_status_from_server::trailing_metadata
grpc_metadata * trailing_metadata
Definition: grpc_types.h:343
grpc::internal::CallOpSendInitialMetadata::send_
bool send_
Definition: call_op_set.h:277
grpc::internal::CallOpClientRecvStatus::FinishOp
void FinishOp(bool *)
Definition: call_op_set.h:796
grpc_slice
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice_type.h:63
grpc::internal::CallOpRecvInitialMetadata::FinishOp
void FinishOp(bool *)
Definition: call_op_set.h:742
grpc::Status::error_message
std::string error_message() const
Return the instance's error message.
Definition: status.h:119
grpc::StatusCode
StatusCode
Definition: status_code_enum.h:26
grpc::SerializationTraits
Defines how to serialize and deserialize some type.
Definition: serialization_traits.h:58
grpc::internal::CallOpGenericRecvMessage::FinishOp
void FinishOp(bool *status)
Definition: call_op_set.h:554
grpc::internal::CallOpRecvMessage::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:436
grpc::internal::CallOpSendInitialMetadata::CallOpSendInitialMetadata
CallOpSendInitialMetadata()
Definition: call_op_set.h:220
call_op_set_interface.h
grpc::internal::CallOpSendInitialMetadata::level
grpc_compression_level level
Definition: call_op_set.h:284
grpc::internal::CallOpSendInitialMetadata::set_compression_level
void set_compression_level(grpc_compression_level level)
Definition: call_op_set.h:232
call_hook.h
grpc_op::op
grpc_op_type op
Operation type, as defined by grpc_op_type.
Definition: grpc_types.h:313
alloc.h
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::count
size_t count
Definition: grpc_types.h:324
grpc_op::grpc_op_data::grpc_op_recv_status_on_client::status_details
grpc_slice * status_details
Definition: grpc_types.h:374
grpc::internal::DeserializeFuncType::DeserializeFuncType
DeserializeFuncType(R *message)
Definition: call_op_set.h:517
compression_types.h
grpc::experimental::InterceptionHookPoints::PRE_SEND_MESSAGE
@ PRE_SEND_MESSAGE
grpc::internal::InterceptorBatchMethodsImpl::SetRecvMessage
void SetRecvMessage(void *message, bool *hijacked_recv_message_failed)
Definition: interceptor_common.h:169
grpc::Status::error_code
StatusCode error_code() const
Return the instance's error code.
Definition: status.h:117
grpc::internal::DeserializeFuncType::Deserialize
Status Deserialize(ByteBuffer *buf) override
Definition: call_op_set.h:518
grpc::internal::CallOpSet::set_output_tag
void set_output_tag(void *return_tag)
Definition: call_op_set.h:937
GRPC_OP_RECV_MESSAGE
@ GRPC_OP_RECV_MESSAGE
Receive a message: 0 or more of these operations can occur for each call.
Definition: grpc_types.h:292
grpc::internal::CallOpClientSendClose::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:628
grpc::WriteOptions
Per-message write options.
Definition: call_op_set.h:80
grpc::internal::CallOpClientSendClose::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:644
serialization_traits.h
client_context.h
grpc::internal::CallNoOp::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:212
grpc_op::grpc_op_data::send_status_from_server
struct grpc_op::grpc_op_data::grpc_op_send_status_from_server send_status_from_server
grpc::internal::CallOpRecvInitialMetadata::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:733
slice.h
grpc::internal::CallOpServerSendStatus::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:694
grpc::internal::CallOpServerSendStatus::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:704
grpc::experimental::InterceptionHookPoints::POST_SEND_MESSAGE
@ POST_SEND_MESSAGE
grpc::internal::DeserializeFuncType::~DeserializeFuncType
~DeserializeFuncType() override
Definition: call_op_set.h:522
grpc_slice_from_static_buffer
GPRAPI grpc_slice grpc_slice_from_static_buffer(const void *source, size_t len)
Create a slice pointing to constant memory.
GRPC_OP_SEND_INITIAL_METADATA
@ GRPC_OP_SEND_INITIAL_METADATA
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:269
grpc::WriteOptions::clear_corked
WriteOptions & clear_corked()
Definition: call_op_set.h:145
config.h
grpc_op::grpc_op_data::send_message
struct grpc_op::grpc_op_data::grpc_op_send_message send_message
grpc::internal::InterceptorBatchMethodsImpl::SetSendMessage
void SetSendMessage(ByteBuffer *buf, const void **msg, bool *fail_send_message, std::function< Status(const void *)> serializer)
Definition: interceptor_common.h:143
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
Log a message.
byte_buffer.h
grpc::internal::Call::call
grpc_call * call() const
Definition: call.h:70
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::metadata
grpc_metadata * metadata
Definition: grpc_types.h:325
grpc::internal::CallOpSet::operator=
CallOpSet & operator=(const CallOpSet &other)
Definition: call_op_set.h:881
grpc_op::grpc_op_data::recv_status_on_client
struct grpc_op::grpc_op_data::grpc_op_recv_status_on_client recv_status_on_client
grpc_compression_level
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:72
grpc_op::grpc_op_data::grpc_op_send_status_from_server::trailing_metadata_count
size_t trailing_metadata_count
Definition: grpc_types.h:342
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::maybe_compression_level
struct grpc_op::grpc_op_data::grpc_op_send_initial_metadata::grpc_op_send_initial_metadata_maybe_compression_level maybe_compression_level
call.h
grpc::internal::CallOpSet::FinalizeResult
bool FinalizeResult(void **tag, bool *status) override
Definition: call_op_set.h:907
grpc::internal::CallOpClientRecvStatus
Definition: call_op_set.h:771
grpc::WriteOptions::set_buffer_hint
WriteOptions & set_buffer_hint()
Sets flag indicating that the write may be buffered and need not go out on the wire immediately.
Definition: call_op_set.h:118
grpc_call_error_to_string
const GRPCAPI char * grpc_call_error_to_string(grpc_call_error error)
Convert grpc_call_error values to a string.
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::grpc_op_send_initial_metadata_maybe_compression_level::is_set
uint8_t is_set
Definition: grpc_types.h:329
grpc::internal::CallOpGenericRecvMessage::got_message
bool got_message
Definition: call_op_set.h:542
grpc::internal::CallOpClientSendClose::CallOpClientSendClose
CallOpClientSendClose()
Definition: call_op_set.h:623
grpc::WriteOptions::clear_no_compression
WriteOptions & clear_no_compression()
Clears flag for the disabling of compression for the next message write.
Definition: call_op_set.h:101
grpc_slice_unref
GPRAPI void grpc_slice_unref(grpc_slice s)
Decrement the ref count of s.
grpc::ByteBuffer::Valid
bool Valid() const
Is this ByteBuffer valid?
Definition: byte_buffer.h:159
grpc::internal::CallOpGenericRecvMessage::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:581
grpc::internal::MetadataMap::GetBinaryErrorDetails
std::string GetBinaryErrorDetails()
Definition: metadata_map.h:40
grpc::internal::InterceptorBatchMethodsImpl::RunInterceptors
bool RunInterceptors()
Definition: interceptor_common.h:239
grpc::internal::CallOpRecvInitialMetadata::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:746
grpc::WriteOptions::Clear
void Clear()
Clear all flags.
Definition: call_op_set.h:85
grpc::WriteOptions::is_last_message
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_op_set.h:173
grpc::internal::DeserializeFunc::Deserialize
virtual Status Deserialize(ByteBuffer *buf)=0
grpc::internal::CallOpRecvMessage
Definition: call_op_set.h:426
grpc::internal::CallOpSendInitialMetadata::SendInitialMetadata
void SendInitialMetadata(std::multimap< std::string, std::string > *metadata, uint32_t flags)
Definition: call_op_set.h:224
grpc::ByteBuffer::Release
void Release()
Forget underlying byte buffer without destroying Use this only for un-owned byte buffers.
Definition: byte_buffer.h:144
grpc::internal::FillMetadataArray
grpc_metadata * FillMetadataArray(const std::multimap< std::string, std::string > &metadata, size_t *metadata_count, const std::string &optional_error_details)
Definition: call_op_set.h:56
grpc_op::grpc_op_data::recv_initial_metadata
struct grpc_op::grpc_op_data::grpc_op_recv_initial_metadata recv_initial_metadata
grpc::internal::CallOpSendInitialMetadata::FinishOp
void FinishOp(bool *)
Definition: call_op_set.h:255
grpc_op::grpc_op_data::grpc_op_send_status_from_server::status_details
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:348
grpc::internal::CallOpClientSendClose::ClientSendClose
void ClientSendClose()
Definition: call_op_set.h:625
GRPC_OP_RECV_STATUS_ON_CLIENT
@ GRPC_OP_RECV_STATUS_ON_CLIENT
Receive status on the client: one and only one must be made on the client.
Definition: grpc_types.h:298
slice.h
grpc_op::grpc_op_data::grpc_op_recv_initial_metadata::recv_initial_metadata
grpc_metadata_array * recv_initial_metadata
Definition: grpc_types.h:356
grpc::internal::CallOpRecvInitialMetadata::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:751
grpc::internal::InterceptorBatchMethodsImpl::SetRecvTrailingMetadata
void SetRecvTrailingMetadata(MetadataMap *map)
Definition: interceptor_common.h:180
grpc::internal::CallOpGenericRecvMessage::AllowNoMessage
void AllowNoMessage()
Definition: call_op_set.h:540
grpc::internal::InterceptorBatchMethodsImpl::SetSendInitialMetadata
void SetSendInitialMetadata(std::multimap< std::string, std::string > *metadata)
Definition: interceptor_common.h:152
grpc::internal::CallOpServerSendStatus::FinishOp
void FinishOp(bool *)
Definition: call_op_set.h:688
grpc::protobuf::util::Status
::absl::Status Status
Definition: config_protobuf.h:106
grpc::WriteOptions::set_no_compression
WriteOptions & set_no_compression()
Sets flag for the disabling of compression for the next message write.
Definition: call_op_set.h:93
grpc::internal::CallOpSet::set_core_cq_tag
void set_core_cq_tag(void *core_cq_tag)
set_core_cq_tag is used to provide a different core CQ tag than "this".
Definition: call_op_set.h:945
grpc::internal::CallOpSendInitialMetadata::is_set
bool is_set
Definition: call_op_set.h:283
grpc_call_start_batch
GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops, size_t nops, void *tag, void *reserved)
Start a batch of operations defined in the array ops; when complete, post a completion of type 'tag' ...
grpc::internal::CallOpSendMessage::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:353
grpc::internal::InterceptorBatchMethodsImpl
Definition: interceptor_common.h:38
grpc::Status::error_details
std::string error_details() const
Return the (binary) error details.
Definition: status.h:122
grpc::internal::InterceptorBatchMethodsImpl::SetSendTrailingMetadata
void SetSendTrailingMetadata(std::multimap< std::string, std::string > *metadata)
Definition: interceptor_common.h:164
grpc::internal::CallOpRecvMessage::RecvMessage
void RecvMessage(R *message)
Definition: call_op_set.h:428
grpc_metadata::key
grpc_slice key
the key, value values are expected to line up with grpc_mdelem: if changing them, update metadata....
Definition: grpc_types.h:213
grpc::internal::CallOpSendInitialMetadata::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:261
GRPC_OP_SEND_CLOSE_FROM_CLIENT
@ GRPC_OP_SEND_CLOSE_FROM_CLIENT
Send a close from the client: one and only one instance MUST be sent from the client,...
Definition: grpc_types.h:278
string_ref.h
grpc::WriteOptions::clear_buffer_hint
WriteOptions & clear_buffer_hint()
Clears flag indicating that the write may be buffered and need not go out on the wire immediately.
Definition: call_op_set.h:127
grpc::internal::InterceptorBatchMethodsImpl::AddInterceptionHookPoint
void AddInterceptionHookPoint(experimental::InterceptionHookPoints type)
Definition: interceptor_common.h:79
grpc::internal::CallNoOp
Default argument for CallOpSet.
Definition: call_op_set.h:206
grpc::internal::CallOpServerSendStatus::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:707
grpc::internal::CallOpRecvMessage::AllowNoMessage
void AllowNoMessage()
Definition: call_op_set.h:431
grpc::SliceReferencingString
grpc_slice SliceReferencingString(const std::string &str)
Definition: slice.h:132
grpc::internal::CallOpSet::ContinueFinalizeResultAfterInterception
void ContinueFinalizeResultAfterInterception() override
Definition: call_op_set.h:985
grpc::internal::CallOpSendMessage::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:344
grpc::experimental::InterceptionHookPoints::PRE_RECV_INITIAL_METADATA
@ PRE_RECV_INITIAL_METADATA
The following three are for hijacked clients only.