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