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