GRPC C++  1.78.1
call_op_set.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2018 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #ifndef GRPCPP_IMPL_CALL_OP_SET_H
20 #define GRPCPP_IMPL_CALL_OP_SET_H
21 
23 #include <grpc/grpc.h>
25 #include <grpc/impl/grpc_types.h>
26 #include <grpc/slice.h>
27 #include <grpc/support/alloc.h>
28 #include <grpcpp/client_context.h>
30 #include <grpcpp/impl/call.h>
31 #include <grpcpp/impl/call_hook.h>
38 #include <grpcpp/support/config.h>
39 #include <grpcpp/support/slice.h>
41 
42 #include <cstring>
43 #include <map>
44 #include <memory>
45 
46 #include "absl/log/absl_check.h"
47 #include "absl/log/absl_log.h"
48 
49 namespace grpc {
50 
51 namespace internal {
52 class Call;
53 class CallHook;
54 
55 // TODO(yangg) if the map is changed before we send, the pointers will be a
56 // mess. Make sure it does not happen.
58  const std::multimap<std::string, std::string>& metadata,
59  size_t* metadata_count, const std::string& optional_error_details) {
60  *metadata_count = metadata.size() + (optional_error_details.empty() ? 0 : 1);
61  if (*metadata_count == 0) {
62  return nullptr;
63  }
64  grpc_metadata* metadata_array = static_cast<grpc_metadata*>(
65  gpr_malloc((*metadata_count) * sizeof(grpc_metadata)));
66  size_t i = 0;
67  for (auto iter = metadata.cbegin(); iter != metadata.cend(); ++iter, ++i) {
68  metadata_array[i].key = SliceReferencingString(iter->first);
69  metadata_array[i].value = SliceReferencingString(iter->second);
70  }
71  if (!optional_error_details.empty()) {
72  metadata_array[i].key = grpc_slice_from_static_buffer(
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>
297  SendMessage(const M& message, WriteOptions options,
299 
300  template <class M>
302  SendMessage(const M& message,
304  return SendMessage(message, WriteOptions(), allocator);
305  }
306 
310  template <class M>
312  SendMessagePtr(const M* message, WriteOptions options,
314 
317  template <class M>
319  SendMessagePtr(const M* message,
321  return SendMessagePtr(message, WriteOptions(), allocator);
322  }
323 
324  protected:
325  void AddOp(grpc_op* ops, size_t* nops) {
326  if (msg_ == nullptr && !send_buf_.Valid()) return;
327  if (hijacked_) {
328  serializer_ = nullptr;
329  return;
330  }
331  if (msg_ != nullptr) {
332  ABSL_CHECK(serializer_(msg_).ok());
333  }
334  serializer_ = nullptr;
335  grpc_op* op = &ops[(*nops)++];
336  op->op = GRPC_OP_SEND_MESSAGE;
337  op->flags = write_options_.flags();
338  op->reserved = nullptr;
339  op->data.send_message.send_message = send_buf_.c_buffer();
340  // Flags are per-message: clear them after use.
341  write_options_.Clear();
342  }
343  void FinishOp(bool* status) {
344  if (msg_ == nullptr && !send_buf_.Valid()) return;
345  send_buf_.Clear();
346  if (hijacked_ && failed_send_) {
347  // Hijacking interceptor failed this Op
348  *status = false;
349  } else if (!*status) {
350  // This Op was passed down to core and the Op failed
351  failed_send_ = true;
352  }
353  }
354 
356  InterceptorBatchMethodsImpl* interceptor_methods) {
357  if (msg_ == nullptr && !send_buf_.Valid()) return;
358  interceptor_methods->AddInterceptionHookPoint(
360  interceptor_methods->SetSendMessage(&send_buf_, &msg_, &failed_send_,
361  serializer_);
362  }
363 
365  InterceptorBatchMethodsImpl* interceptor_methods) {
366  if (msg_ != nullptr || send_buf_.Valid()) {
367  interceptor_methods->AddInterceptionHookPoint(
369  }
370  send_buf_.Clear();
371  msg_ = nullptr;
372  // The contents of the SendMessage value that was previously set
373  // has had its references stolen by core's operations
374  interceptor_methods->SetSendMessage(nullptr, nullptr, &failed_send_,
375  nullptr);
376  }
377 
378  void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) {
379  hijacked_ = true;
380  }
381 
382  private:
383  const void* msg_ = nullptr; // The original non-serialized message
384  bool hijacked_ = false;
385  bool failed_send_ = false;
386  ByteBuffer send_buf_;
387  WriteOptions write_options_;
388  std::function<Status(const void*)> serializer_;
389 };
390 
391 template <class M>
393  const M& message, WriteOptions options,
395  write_options_ = options;
396  // Serialize immediately since we do not have access to the message pointer
397  bool own_buf;
398  Status result = Serialize(allocator, message, send_buf_.bbuf_ptr(), &own_buf);
399  if (!own_buf) {
400  send_buf_.Duplicate();
401  }
402  return result;
403 }
404 
405 template <class M>
407  const M* message, WriteOptions options,
409  msg_ = message;
410  write_options_ = options;
411  // Store the serializer for later since we have access to the message
412  serializer_ = [this, allocator](const void* message) {
413  bool own_buf;
414  // TODO(vjpai): Remove the void below when possible
415  // The void in the template parameter below should not be needed
416  // (since it should be implicit) but is needed due to an observed
417  // difference in behavior between clang and gcc for certain internal users
418  Status result = Serialize(allocator, *static_cast<const M*>(message),
419  send_buf_.bbuf_ptr(), &own_buf);
420  if (!own_buf) {
421  send_buf_.Duplicate();
422  }
423  return result;
424  };
425  return Status();
426 }
427 
428 template <class R>
430  public:
431  void RecvMessage(R* message) { message_ = message; }
432 
433  // Do not change status if no message is received.
434  void AllowNoMessage() { allow_not_getting_message_ = true; }
435 
436  bool got_message = false;
437 
438  protected:
439  void AddOp(grpc_op* ops, size_t* nops) {
440  if (message_ == nullptr || hijacked_) return;
441  grpc_op* op = &ops[(*nops)++];
442  op->op = GRPC_OP_RECV_MESSAGE;
443  op->flags = 0;
444  op->reserved = nullptr;
445  op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr();
446  }
447 
448  void FinishOp(bool* status) {
449  if (message_ == nullptr) return;
450  if (recv_buf_.Valid()) {
451  if (*status) {
452  got_message = *status =
453  grpc::Deserialize(recv_buf_.bbuf_ptr(), message_).ok();
454  recv_buf_.Release();
455  } else {
456  got_message = false;
457  recv_buf_.Clear();
458  }
459  } else if (hijacked_) {
460  if (hijacked_recv_message_failed_) {
461  FinishOpRecvMessageFailureHandler(status);
462  } else {
463  // The op was hijacked and it was successful. There is no further action
464  // to be performed since the message is already in its non-serialized
465  // form.
466  }
467  } else {
468  FinishOpRecvMessageFailureHandler(status);
469  }
470  }
471 
473  InterceptorBatchMethodsImpl* interceptor_methods) {
474  if (message_ == nullptr) return;
475  interceptor_methods->SetRecvMessage(message_,
476  &hijacked_recv_message_failed_);
477  }
478 
480  InterceptorBatchMethodsImpl* interceptor_methods) {
481  if (message_ == nullptr) return;
482  interceptor_methods->AddInterceptionHookPoint(
484  if (!got_message) interceptor_methods->SetRecvMessage(nullptr, nullptr);
485  }
486  void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
487  hijacked_ = true;
488  if (message_ == nullptr) return;
489  interceptor_methods->AddInterceptionHookPoint(
491  got_message = true;
492  }
493 
494  private:
495  // Sets got_message and \a status for a failed recv message op
496  void FinishOpRecvMessageFailureHandler(bool* status) {
497  got_message = false;
498  if (!allow_not_getting_message_) {
499  *status = false;
500  }
501  }
502 
503  R* message_ = nullptr;
504  ByteBuffer recv_buf_;
505  bool allow_not_getting_message_ = false;
506  bool hijacked_ = false;
507  bool hijacked_recv_message_failed_ = false;
508 };
509 
511  public:
512  virtual Status Deserialize(ByteBuffer* buf) = 0;
513  virtual ~DeserializeFunc() {}
514 };
515 
516 template <class R>
517 class DeserializeFuncType final : public DeserializeFunc {
518  public:
519  explicit DeserializeFuncType(R* message) : message_(message) {}
520  Status Deserialize(ByteBuffer* buf) override {
521  return grpc::Deserialize(buf->bbuf_ptr(), message_);
522  }
523 
524  ~DeserializeFuncType() override {}
525 
526  private:
527  R* message_; // Not a managed pointer because management is external to this
528 };
529 
531  public:
532  template <class R>
533  void RecvMessage(R* message) {
534  // Use an explicit base class pointer to avoid resolution error in the
535  // following unique_ptr::reset for some old implementations.
536  DeserializeFunc* func = new DeserializeFuncType<R>(message);
537  deserialize_.reset(func);
538  message_ = message;
539  }
540 
541  // Do not change status if no message is received.
542  void AllowNoMessage() { allow_not_getting_message_ = true; }
543 
544  bool got_message = false;
545 
546  protected:
547  void AddOp(grpc_op* ops, size_t* nops) {
548  if (!deserialize_ || hijacked_) return;
549  grpc_op* op = &ops[(*nops)++];
550  op->op = GRPC_OP_RECV_MESSAGE;
551  op->flags = 0;
552  op->reserved = nullptr;
553  op->data.recv_message.recv_message = recv_buf_.c_buffer_ptr();
554  }
555 
556  void FinishOp(bool* status) {
557  if (!deserialize_) return;
558  if (recv_buf_.Valid()) {
559  if (*status) {
560  got_message = true;
561  *status = deserialize_->Deserialize(&recv_buf_).ok();
562  recv_buf_.Release();
563  } else {
564  got_message = false;
565  recv_buf_.Clear();
566  }
567  } else if (hijacked_) {
568  if (hijacked_recv_message_failed_) {
569  FinishOpRecvMessageFailureHandler(status);
570  } else {
571  // The op was hijacked and it was successful. There is no further action
572  // to be performed since the message is already in its non-serialized
573  // form.
574  }
575  } else {
576  got_message = false;
577  if (!allow_not_getting_message_) {
578  *status = false;
579  }
580  }
581  }
582 
584  InterceptorBatchMethodsImpl* interceptor_methods) {
585  if (!deserialize_) return;
586  interceptor_methods->SetRecvMessage(message_,
587  &hijacked_recv_message_failed_);
588  }
589 
591  InterceptorBatchMethodsImpl* interceptor_methods) {
592  if (!deserialize_) return;
593  interceptor_methods->AddInterceptionHookPoint(
595  if (!got_message) interceptor_methods->SetRecvMessage(nullptr, nullptr);
596  deserialize_.reset();
597  }
598  void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
599  hijacked_ = true;
600  if (!deserialize_) return;
601  interceptor_methods->AddInterceptionHookPoint(
603  got_message = true;
604  }
605 
606  private:
607  // Sets got_message and \a status for a failed recv message op
608  void FinishOpRecvMessageFailureHandler(bool* status) {
609  got_message = false;
610  if (!allow_not_getting_message_) {
611  *status = false;
612  }
613  }
614 
615  void* message_ = nullptr;
616  std::unique_ptr<DeserializeFunc> deserialize_;
617  ByteBuffer recv_buf_;
618  bool allow_not_getting_message_ = false;
619  bool hijacked_ = false;
620  bool hijacked_recv_message_failed_ = false;
621 };
622 
624  public:
625  CallOpClientSendClose() : send_(false) {}
626 
627  void ClientSendClose() { send_ = true; }
628 
629  protected:
630  void AddOp(grpc_op* ops, size_t* nops) {
631  if (!send_ || hijacked_) return;
632  grpc_op* op = &ops[(*nops)++];
634  op->flags = 0;
635  op->reserved = nullptr;
636  }
637  void FinishOp(bool* /*status*/) { send_ = false; }
638 
640  InterceptorBatchMethodsImpl* interceptor_methods) {
641  if (!send_) return;
642  interceptor_methods->AddInterceptionHookPoint(
644  }
645 
647  InterceptorBatchMethodsImpl* /*interceptor_methods*/) {}
648 
649  void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) {
650  hijacked_ = true;
651  }
652 
653  private:
654  bool hijacked_ = false;
655  bool send_;
656 };
657 
659  public:
660  CallOpServerSendStatus() : send_status_available_(false) {}
661 
663  std::multimap<std::string, std::string>* trailing_metadata,
664  const Status& status) {
665  send_error_details_ = status.error_details();
666  metadata_map_ = trailing_metadata;
667  send_status_available_ = true;
668  send_status_code_ = static_cast<grpc_status_code>(status.error_code());
669  send_error_message_ = status.error_message();
670  }
671 
672  protected:
673  void AddOp(grpc_op* ops, size_t* nops) {
674  if (!send_status_available_ || hijacked_) return;
675  trailing_metadata_ = FillMetadataArray(
676  *metadata_map_, &trailing_metadata_count_, send_error_details_);
677  grpc_op* op = &ops[(*nops)++];
680  trailing_metadata_count_;
681  op->data.send_status_from_server.trailing_metadata = trailing_metadata_;
682  op->data.send_status_from_server.status = send_status_code_;
683  error_message_slice_ = SliceReferencingString(send_error_message_);
685  send_error_message_.empty() ? nullptr : &error_message_slice_;
686  op->flags = 0;
687  op->reserved = nullptr;
688  }
689 
690  void FinishOp(bool* /*status*/) {
691  if (!send_status_available_ || hijacked_) return;
692  gpr_free(trailing_metadata_);
693  send_status_available_ = false;
694  }
695 
697  InterceptorBatchMethodsImpl* interceptor_methods) {
698  if (!send_status_available_) return;
699  interceptor_methods->AddInterceptionHookPoint(
701  interceptor_methods->SetSendTrailingMetadata(metadata_map_);
702  interceptor_methods->SetSendStatus(&send_status_code_, &send_error_details_,
703  &send_error_message_);
704  }
705 
707  InterceptorBatchMethodsImpl* /*interceptor_methods*/) {}
708 
709  void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) {
710  hijacked_ = true;
711  }
712 
713  private:
714  bool hijacked_ = false;
715  bool send_status_available_;
716  grpc_status_code send_status_code_;
717  std::string send_error_details_;
718  std::string send_error_message_;
719  size_t trailing_metadata_count_;
720  std::multimap<std::string, std::string>* metadata_map_;
721  grpc_metadata* trailing_metadata_;
722  grpc_slice error_message_slice_;
723 };
724 
726  public:
727  CallOpRecvInitialMetadata() : metadata_map_(nullptr) {}
728 
730  context->initial_metadata_received_ = true;
731  metadata_map_ = &context->recv_initial_metadata_;
732  }
733 
734  protected:
735  void AddOp(grpc_op* ops, size_t* nops) {
736  if (metadata_map_ == nullptr || hijacked_) return;
737  grpc_op* op = &ops[(*nops)++];
739  op->data.recv_initial_metadata.recv_initial_metadata = metadata_map_->arr();
740  op->flags = 0;
741  op->reserved = nullptr;
742  }
743 
744  void FinishOp(bool* /*status*/) {
745  if (metadata_map_ == nullptr || hijacked_) return;
746  }
747 
749  InterceptorBatchMethodsImpl* interceptor_methods) {
750  interceptor_methods->SetRecvInitialMetadata(metadata_map_);
751  }
752 
754  InterceptorBatchMethodsImpl* interceptor_methods) {
755  if (metadata_map_ == nullptr) return;
756  interceptor_methods->AddInterceptionHookPoint(
758  metadata_map_ = nullptr;
759  }
760 
761  void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
762  hijacked_ = true;
763  if (metadata_map_ == nullptr) return;
764  interceptor_methods->AddInterceptionHookPoint(
766  }
767 
768  private:
769  bool hijacked_ = false;
770  MetadataMap* metadata_map_;
771 };
772 
774  public:
776  : metadata_map_(nullptr),
777  recv_status_(nullptr),
778  debug_error_string_(nullptr) {}
779 
780  void ClientRecvStatus(grpc::ClientContext* context, Status* status) {
781  client_context_ = context;
782  metadata_map_ = &client_context_->trailing_metadata_;
783  recv_status_ = status;
784  error_message_ = grpc_empty_slice();
785  }
786 
787  protected:
788  void AddOp(grpc_op* ops, size_t* nops) {
789  if (recv_status_ == nullptr || hijacked_) return;
790  grpc_op* op = &ops[(*nops)++];
792  op->data.recv_status_on_client.trailing_metadata = metadata_map_->arr();
793  op->data.recv_status_on_client.status = &status_code_;
794  op->data.recv_status_on_client.status_details = &error_message_;
795  op->data.recv_status_on_client.error_string = &debug_error_string_;
796  op->flags = 0;
797  op->reserved = nullptr;
798  }
799 
800  void FinishOp(bool* /*status*/) {
801  if (recv_status_ == nullptr || hijacked_) return;
802  if (static_cast<StatusCode>(status_code_) == StatusCode::OK) {
803  *recv_status_ = Status();
804  ABSL_DCHECK_EQ(debug_error_string_, nullptr);
805  } else {
806  *recv_status_ =
807  Status(static_cast<StatusCode>(status_code_),
808  GRPC_SLICE_IS_EMPTY(error_message_)
809  ? std::string()
810  : std::string(GRPC_SLICE_START_PTR(error_message_),
811  GRPC_SLICE_END_PTR(error_message_)),
812  metadata_map_->GetBinaryErrorDetails());
813  if (debug_error_string_ != nullptr) {
814  client_context_->set_debug_error_string(debug_error_string_);
815  gpr_free(const_cast<char*>(debug_error_string_));
816  }
817  }
818  // TODO(soheil): Find callers that set debug string even for status OK,
819  // and fix them.
820  grpc_slice_unref(error_message_);
821  }
822 
824  InterceptorBatchMethodsImpl* interceptor_methods) {
825  interceptor_methods->SetRecvStatus(recv_status_);
826  interceptor_methods->SetRecvTrailingMetadata(metadata_map_);
827  }
828 
830  InterceptorBatchMethodsImpl* interceptor_methods) {
831  if (recv_status_ == nullptr) return;
832  interceptor_methods->AddInterceptionHookPoint(
834  recv_status_ = nullptr;
835  }
836 
837  void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
838  hijacked_ = true;
839  if (recv_status_ == nullptr) return;
840  interceptor_methods->AddInterceptionHookPoint(
842  }
843 
844  private:
845  bool hijacked_ = false;
846  grpc::ClientContext* client_context_;
847  MetadataMap* metadata_map_;
848  Status* recv_status_;
849  const char* debug_error_string_;
850  grpc_status_code status_code_;
851  grpc_slice error_message_;
852 };
853 
854 template <class Op1 = CallNoOp<1>, class Op2 = CallNoOp<2>,
855  class Op3 = CallNoOp<3>, class Op4 = CallNoOp<4>,
856  class Op5 = CallNoOp<5>, class Op6 = CallNoOp<6>>
857 class CallOpSet;
858 
865 template <class Op1, class Op2, class Op3, class Op4, class Op5, class Op6>
866 class CallOpSet : public CallOpSetInterface,
867  public Op1,
868  public Op2,
869  public Op3,
870  public Op4,
871  public Op5,
872  public Op6 {
873  public:
874  CallOpSet() : core_cq_tag_(this), return_tag_(this) {}
875  // The copy constructor and assignment operator reset the value of
876  // core_cq_tag_, return_tag_, done_intercepting_ and interceptor_methods_
877  // since those are only meaningful on a specific object, not across objects.
878  CallOpSet(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 
885  CallOpSet& operator=(const CallOpSet& other) {
886  if (&other == this) {
887  return *this;
888  }
889  core_cq_tag_ = this;
890  return_tag_ = this;
891  call_ = other.call_;
892  done_intercepting_ = false;
893  interceptor_methods_ = InterceptorBatchMethodsImpl();
894  return *this;
895  }
896 
897  void FillOps(Call* call) override {
898  done_intercepting_ = false;
899  grpc_call_ref(call->call());
900  call_ =
901  *call; // It's fine to create a copy of call since it's just pointers
902 
903  if (RunInterceptors()) {
905  } else {
906  // After the interceptors are run, ContinueFillOpsAfterInterception will
907  // be run
908  }
909  }
910 
911  bool FinalizeResult(void** tag, bool* status) override {
912  if (done_intercepting_) {
913  // Complete the avalanching since we are done with this batch of ops
914  call_.cq()->CompleteAvalanching();
915  // We have already finished intercepting and filling in the results. This
916  // round trip from the core needed to be made because interceptors were
917  // run
918  *tag = return_tag_;
919  *status = saved_status_;
920  grpc_call_unref(call_.call());
921  return true;
922  }
923 
924  this->Op1::FinishOp(status);
925  this->Op2::FinishOp(status);
926  this->Op3::FinishOp(status);
927  this->Op4::FinishOp(status);
928  this->Op5::FinishOp(status);
929  this->Op6::FinishOp(status);
930  saved_status_ = *status;
931  if (RunInterceptorsPostRecv()) {
932  *tag = return_tag_;
933  grpc_call_unref(call_.call());
934  return true;
935  }
936  // Interceptors are going to be run, so we can't return the tag just yet.
937  // After the interceptors are run, ContinueFinalizeResultAfterInterception
938  return false;
939  }
940 
941  void set_output_tag(void* return_tag) { return_tag_ = return_tag; }
942 
943  void* core_cq_tag() override { return core_cq_tag_; }
944 
949  void set_core_cq_tag(void* core_cq_tag) { core_cq_tag_ = core_cq_tag; }
950 
951  // This will be called while interceptors are run if the RPC is a hijacked
952  // RPC. This should set hijacking state for each of the ops.
953  void SetHijackingState() override {
954  this->Op1::SetHijackingState(&interceptor_methods_);
955  this->Op2::SetHijackingState(&interceptor_methods_);
956  this->Op3::SetHijackingState(&interceptor_methods_);
957  this->Op4::SetHijackingState(&interceptor_methods_);
958  this->Op5::SetHijackingState(&interceptor_methods_);
959  this->Op6::SetHijackingState(&interceptor_methods_);
960  }
961 
962  // Should be called after interceptors are done running
964  static const size_t MAX_OPS = 6;
965  grpc_op ops[MAX_OPS];
966  size_t nops = 0;
967  this->Op1::AddOp(ops, &nops);
968  this->Op2::AddOp(ops, &nops);
969  this->Op3::AddOp(ops, &nops);
970  this->Op4::AddOp(ops, &nops);
971  this->Op5::AddOp(ops, &nops);
972  this->Op6::AddOp(ops, &nops);
973 
974  grpc_call_error err =
975  grpc_call_start_batch(call_.call(), ops, nops, core_cq_tag(), nullptr);
976 
977  if (err != GRPC_CALL_OK) {
978  // A failure here indicates an API misuse; for example, doing a Write
979  // while another Write is already pending on the same RPC or invoking
980  // WritesDone multiple times
981  ABSL_LOG(ERROR) << "API misuse of type " << grpc_call_error_to_string(err)
982  << " observed";
983  ABSL_CHECK(false);
984  }
985  }
986 
987  // Should be called after interceptors are done running on the finalize result
988  // path
990  done_intercepting_ = true;
991  // The following call_start_batch is internally-generated so no need for an
992  // explanatory log on failure.
993  ABSL_CHECK(grpc_call_start_batch(call_.call(), nullptr, 0, core_cq_tag(),
994  nullptr) == GRPC_CALL_OK);
995  }
996 
997  private:
998  // Returns true if no interceptors need to be run
999  bool RunInterceptors() {
1000  interceptor_methods_.ClearState();
1001  interceptor_methods_.SetCallOpSetInterface(this);
1002  interceptor_methods_.SetCall(&call_);
1003  this->Op1::SetInterceptionHookPoint(&interceptor_methods_);
1004  this->Op2::SetInterceptionHookPoint(&interceptor_methods_);
1005  this->Op3::SetInterceptionHookPoint(&interceptor_methods_);
1006  this->Op4::SetInterceptionHookPoint(&interceptor_methods_);
1007  this->Op5::SetInterceptionHookPoint(&interceptor_methods_);
1008  this->Op6::SetInterceptionHookPoint(&interceptor_methods_);
1009  if (interceptor_methods_.InterceptorsListEmpty()) {
1010  return true;
1011  }
1012  // This call will go through interceptors and would need to
1013  // schedule new batches, so delay completion queue shutdown
1014  call_.cq()->RegisterAvalanching();
1015  return interceptor_methods_.RunInterceptors();
1016  }
1017  // Returns true if no interceptors need to be run
1018  bool RunInterceptorsPostRecv() {
1019  // Call and OpSet had already been set on the set state.
1020  // SetReverse also clears previously set hook points
1021  interceptor_methods_.SetReverse();
1022  this->Op1::SetFinishInterceptionHookPoint(&interceptor_methods_);
1023  this->Op2::SetFinishInterceptionHookPoint(&interceptor_methods_);
1024  this->Op3::SetFinishInterceptionHookPoint(&interceptor_methods_);
1025  this->Op4::SetFinishInterceptionHookPoint(&interceptor_methods_);
1026  this->Op5::SetFinishInterceptionHookPoint(&interceptor_methods_);
1027  this->Op6::SetFinishInterceptionHookPoint(&interceptor_methods_);
1028  return interceptor_methods_.RunInterceptors();
1029  }
1030 
1031  void* core_cq_tag_;
1032  void* return_tag_;
1033  Call call_;
1034  bool done_intercepting_ = false;
1035  InterceptorBatchMethodsImpl interceptor_methods_;
1036  bool saved_status_;
1037 };
1038 
1039 } // namespace internal
1040 } // namespace grpc
1041 
1042 #endif // GRPCPP_IMPL_CALL_OP_SET_H
grpc::internal::CallOpSendMessage::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:378
gpr_malloc
GPRAPI void * gpr_malloc(size_t size)
malloc.
grpc::internal::Call::cq
grpc::CompletionQueue * cq() const
Definition: call.h:71
grpc::internal::CallOpRecvInitialMetadata
Definition: call_op_set.h:725
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:338
grpc_op::flags
uint32_t flags
Write flags bitset for grpc_begin_messages.
Definition: grpc_types.h:314
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:479
grpc_empty_slice
GPRAPI grpc_slice grpc_empty_slice(void)
grpc_call_error
grpc_call_error
Result of a grpc call.
Definition: grpc_types.h:139
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:788
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:371
grpc::internal::CallOpClientSendClose
Definition: call_op_set.h:623
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:372
grpc::experimental::InterceptionHookPoints::PRE_SEND_CLOSE
@ PRE_SEND_CLOSE
grpc::internal::CallOpRecvMessage::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:486
grpc::internal::CallOpClientSendClose::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:649
grpc::internal::CallOpSet::CallOpSet
CallOpSet()
Definition: call_op_set.h:874
grpc::internal::CallOpSendInitialMetadata::flags_
uint32_t flags_
Definition: call_op_set.h:279
grpc::internal::CallOpGenericRecvMessage
Definition: call_op_set.h:530
grpc::internal::CallOpRecvInitialMetadata::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:761
grpc::internal::CallOpServerSendStatus
Definition: call_op_set.h:658
GRPC_SLICE_START_PTR
#define GRPC_SLICE_START_PTR(slice)
Definition: slice_type.h:98
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:139
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:547
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc::internal::CallOpSet
Primary implementation of CallOpSetInterface.
Definition: completion_queue.h:97
grpc::internal::CallOpSendMessage::SendMessagePtr
GRPC_MUST_USE_RESULT Status SendMessagePtr(const M *message, WriteOptions options, grpc_event_engine::experimental::MemoryAllocator *allocator)
Send message using options for the write.
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:329
grpc::Deserialize
auto Deserialize(BufferPtr buffer, Message *msg)
Definition: serialization_traits.h:120
grpc::internal::CallOpSendMessage
Definition: call_op_set.h:289
GRPC_SLICE_END_PTR
#define GRPC_SLICE_END_PTR(slice)
Definition: slice_type.h:107
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_status_code
grpc_status_code
Definition: status.h:28
grpc::internal::InterceptorBatchMethodsImpl::SetRecvInitialMetadata
void SetRecvInitialMetadata(MetadataMap *map)
Definition: interceptor_common.h:174
grpc::WriteOptions::set_last_message
WriteOptions & set_last_message()
last-message bit: indicates this is the last message in a stream client-side: makes Write the equival...
Definition: call_op_set.h:158
GRPC_MUST_USE_RESULT
#define GRPC_MUST_USE_RESULT
Definition: port_platform.h:667
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:343
grpc_op::reserved
void * reserved
Reserved for future usage.
Definition: grpc_types.h:316
grpc::internal::InterceptorBatchMethodsImpl::SetCallOpSetInterface
void SetCallOpSetInterface(CallOpSetInterface *ops)
Definition: interceptor_common.h:220
grpc::internal::CallOpGenericRecvMessage::RecvMessage
void RecvMessage(R *message)
Definition: call_op_set.h:533
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:897
intercepted_channel.h
grpc::internal::InterceptorBatchMethodsImpl::SetCall
void SetCall(Call *call)
Definition: interceptor_common.h:216
grpc::internal::InterceptorBatchMethodsImpl::InterceptorsListEmpty
bool InterceptorsListEmpty()
Definition: interceptor_common.h:224
grpc::internal::CallOpClientRecvStatus::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:837
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:36
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:141
grpc::WriteOptions::WriteOptions
WriteOptions()
Definition: call_op_set.h:83
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:829
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:219
completion_queue_tag.h
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:637
grpc::internal::CallOpServerSendStatus::ServerSendStatus
void ServerSendStatus(std::multimap< std::string, std::string > *trailing_metadata, const Status &status)
Definition: call_op_set.h:662
grpc::internal::CallOpClientRecvStatus::CallOpClientRecvStatus
CallOpClientRecvStatus()
Definition: call_op_set.h:775
grpc::internal::CallNoOp::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:211
grpc_call_ref
GRPCAPI void grpc_call_ref(grpc_call *call)
Ref a call.
GRPC_WRITE_NO_COMPRESS
#define GRPC_WRITE_NO_COMPRESS
Force compression to be disabled for a particular write (start_write/add_metadata).
Definition: grpc_types.h:188
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:472
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:673
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:448
grpc_types.h
grpc::internal::CallOpSet::CallOpSet
CallOpSet(const CallOpSet &other)
Definition: call_op_set.h:878
grpc::WriteOptions::flags
uint32_t flags() const
Returns raw flags bitset.
Definition: call_op_set.h:89
gpr_free
GPRAPI void gpr_free(void *ptr)
free
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:660
grpc::internal::CallOpSet::ContinueFillOpsAfterInterception
void ContinueFillOpsAfterInterception() override
Definition: call_op_set.h:963
grpc_op::grpc_op_data::grpc_op_recv_message::recv_message
struct grpc_byte_buffer ** recv_message
Definition: grpc_types.h:363
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:34
grpc::internal::DeserializeFunc
Definition: call_op_set.h:510
grpc_metadata
A single metadata element.
Definition: grpc_types.h:209
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:325
grpc::Serialize
auto Serialize(grpc_event_engine::experimental::MemoryAllocator *allocator, const Message &msg, BufferPtr buffer, bool *own_buffer)
Definition: serialization_traits.h:113
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:943
grpc::internal::CallOpRecvInitialMetadata::CallOpRecvInitialMetadata
CallOpRecvInitialMetadata()
Definition: call_op_set.h:727
grpc::internal::CallOpGenericRecvMessage::SetHijackingState
void SetHijackingState(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:598
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:287
grpc::internal::CallOpRecvMessage::got_message
bool got_message
Definition: call_op_set.h:436
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:282
grpc::internal::CallOpRecvInitialMetadata::RecvInitialMetadata
void RecvInitialMetadata(grpc::ClientContext *context)
Definition: call_op_set.h:729
grpc::internal::CallOpClientRecvStatus::ClientRecvStatus
void ClientRecvStatus(grpc::ClientContext *context, Status *status)
Definition: call_op_set.h:780
GRPC_SLICE_IS_EMPTY
#define GRPC_SLICE_IS_EMPTY(slice)
Definition: slice_type.h:109
grpc::internal::CallOpSendMessage::SendMessage
GRPC_MUST_USE_RESULT Status SendMessage(const M &message, grpc_event_engine::experimental::MemoryAllocator *allocator)
Definition: call_op_set.h:302
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:31
grpc_call_unref
GRPCAPI void grpc_call_unref(grpc_call *call)
Unref a call.
grpc_op::grpc_op_data::grpc_op_send_status_from_server::status
grpc_status_code status
Definition: grpc_types.h:343
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:377
completion_queue.h
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:194
grpc::internal::CallOpGenericRecvMessage::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:590
grpc::WriteOptions::is_corked
bool is_corked() const
Definition: call_op_set.h:151
grpc::internal::CallOpSendMessage::SendMessage
GRPC_MUST_USE_RESULT Status SendMessage(const M &message, WriteOptions options, grpc_event_engine::experimental::MemoryAllocator *allocator)
Send message using options for the write.
grpc::ByteBuffer::Clear
void Clear()
Remove all data.
Definition: byte_buffer.h:127
grpc_metadata::value
grpc_slice value
Definition: grpc_types.h:213
grpc.h
grpc::internal::DeserializeFuncType
Definition: call_op_set.h:517
grpc::ByteBuffer
A sequence of bytes.
Definition: byte_buffer.h:59
GRPC_WRITE_BUFFER_HINT
#define GRPC_WRITE_BUFFER_HINT
Write Flags:
Definition: grpc_types.h:185
grpc::internal::CallOpClientRecvStatus::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:823
grpc::internal::DeserializeFunc::~DeserializeFunc
virtual ~DeserializeFunc()
Definition: call_op_set.h:513
grpc_op
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments)
Definition: grpc_types.h:310
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:272
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:639
grpc::internal::CallOpSet::SetHijackingState
void SetHijackingState() override
Definition: call_op_set.h:953
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:190
grpc_op::grpc_op_data::grpc_op_send_status_from_server::trailing_metadata
grpc_metadata * trailing_metadata
Definition: grpc_types.h:342
grpc::internal::CallOpSendInitialMetadata::send_
bool send_
Definition: call_op_set.h:278
grpc::internal::CallOpClientRecvStatus::FinishOp
void FinishOp(bool *)
Definition: call_op_set.h:800
grpc_slice
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice_type.h:62
grpc::internal::CallOpRecvInitialMetadata::FinishOp
void FinishOp(bool *)
Definition: call_op_set.h:744
grpc::Status::error_message
std::string error_message() const
Return the instance's error message.
Definition: status.h:119
grpc::StatusCode
StatusCode
Definition: status_code_enum.h:26
grpc::internal::CallOpGenericRecvMessage::FinishOp
void FinishOp(bool *status)
Definition: call_op_set.h:556
grpc::internal::CallOpRecvMessage::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:439
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
call_hook.h
grpc_op::op
grpc_op_type op
Operation type, as defined by grpc_op_type.
Definition: grpc_types.h:312
alloc.h
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::count
size_t count
Definition: grpc_types.h:323
grpc_op::grpc_op_data::grpc_op_recv_status_on_client::status_details
grpc_slice * status_details
Definition: grpc_types.h:373
grpc::internal::DeserializeFuncType::DeserializeFuncType
DeserializeFuncType(R *message)
Definition: call_op_set.h:519
compression_types.h
grpc::experimental::InterceptionHookPoints::PRE_SEND_MESSAGE
@ PRE_SEND_MESSAGE
grpc::internal::InterceptorBatchMethodsImpl::SetRecvMessage
void SetRecvMessage(void *message, bool *hijacked_recv_message_failed)
Definition: interceptor_common.h:169
grpc::Status::error_code
StatusCode error_code() const
Return the instance's error code.
Definition: status.h:117
grpc::internal::DeserializeFuncType::Deserialize
Status Deserialize(ByteBuffer *buf) override
Definition: call_op_set.h:520
grpc::internal::CallOpSet::set_output_tag
void set_output_tag(void *return_tag)
Definition: call_op_set.h:941
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:291
grpc::internal::CallOpClientSendClose::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:630
grpc::WriteOptions
Per-message write options.
Definition: call_op_set.h:81
grpc::internal::CallOpClientSendClose::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:646
serialization_traits.h
client_context.h
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::internal::CallOpRecvInitialMetadata::AddOp
void AddOp(grpc_op *ops, size_t *nops)
Definition: call_op_set.h:735
slice.h
grpc::internal::CallOpServerSendStatus::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:696
grpc::internal::CallOpServerSendStatus::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *)
Definition: call_op_set.h:706
grpc::experimental::InterceptionHookPoints::POST_SEND_MESSAGE
@ POST_SEND_MESSAGE
grpc::internal::DeserializeFuncType::~DeserializeFuncType
~DeserializeFuncType() override
Definition: call_op_set.h:524
grpc_slice_from_static_buffer
GPRAPI grpc_slice grpc_slice_from_static_buffer(const void *source, size_t len)
Create a slice pointing to constant memory.
GRPC_OP_SEND_INITIAL_METADATA
@ GRPC_OP_SEND_INITIAL_METADATA
Send initial metadata: one and only one instance MUST be sent for each call, unless the call was canc...
Definition: grpc_types.h:268
grpc::WriteOptions::clear_corked
WriteOptions & clear_corked()
Definition: call_op_set.h:146
config.h
grpc_op::grpc_op_data::send_message
struct grpc_op::grpc_op_data::grpc_op_send_message send_message
grpc::internal::InterceptorBatchMethodsImpl::SetSendMessage
void SetSendMessage(ByteBuffer *buf, const void **msg, bool *fail_send_message, std::function< Status(const void *)> serializer)
Definition: interceptor_common.h:143
byte_buffer.h
grpc::internal::CallOpSendMessage::SendMessagePtr
GRPC_MUST_USE_RESULT Status SendMessagePtr(const M *message, grpc_event_engine::experimental::MemoryAllocator *allocator)
This form of SendMessage allows gRPC to reference message beyond the lifetime of SendMessage.
Definition: call_op_set.h:319
grpc::internal::Call::call
grpc_call * call() const
Definition: call.h:70
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::metadata
grpc_metadata * metadata
Definition: grpc_types.h:324
grpc::internal::CallOpSet::operator=
CallOpSet & operator=(const CallOpSet &other)
Definition: call_op_set.h:885
grpc_op::grpc_op_data::recv_status_on_client
struct grpc_op::grpc_op_data::grpc_op_recv_status_on_client recv_status_on_client
grpc_compression_level
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:73
grpc_op::grpc_op_data::grpc_op_send_status_from_server::trailing_metadata_count
size_t trailing_metadata_count
Definition: grpc_types.h:341
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::maybe_compression_level
struct grpc_op::grpc_op_data::grpc_op_send_initial_metadata::grpc_op_send_initial_metadata_maybe_compression_level maybe_compression_level
call.h
grpc::internal::CallOpSet::FinalizeResult
bool FinalizeResult(void **tag, bool *status) override
Definition: call_op_set.h:911
grpc::internal::CallOpClientRecvStatus
Definition: call_op_set.h:773
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_call_error_to_string
const GRPCAPI char * grpc_call_error_to_string(grpc_call_error error)
Convert grpc_call_error values to a string.
grpc_op::grpc_op_data::grpc_op_send_initial_metadata::grpc_op_send_initial_metadata_maybe_compression_level::is_set
uint8_t is_set
Definition: grpc_types.h:328
grpc::internal::CallOpGenericRecvMessage::got_message
bool got_message
Definition: call_op_set.h:544
grpc::internal::CallOpClientSendClose::CallOpClientSendClose
CallOpClientSendClose()
Definition: call_op_set.h:625
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_event_engine::experimental::MemoryAllocator
Definition: memory_allocator.h:33
grpc_slice_unref
GPRAPI void grpc_slice_unref(grpc_slice s)
Decrement the ref count of s.
grpc::ByteBuffer::Valid
bool Valid() const
Is this ByteBuffer valid?
Definition: byte_buffer.h:158
grpc::internal::CallOpGenericRecvMessage::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:583
grpc::internal::MetadataMap::GetBinaryErrorDetails
std::string GetBinaryErrorDetails()
Definition: metadata_map.h:39
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:748
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
memory_allocator.h
grpc::internal::DeserializeFunc::Deserialize
virtual Status Deserialize(ByteBuffer *buf)=0
grpc::internal::CallOpRecvMessage
Definition: call_op_set.h:429
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:143
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:57
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:347
grpc::internal::CallOpClientSendClose::ClientSendClose
void ClientSendClose()
Definition: call_op_set.h:627
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:297
slice.h
grpc_op::grpc_op_data::grpc_op_recv_initial_metadata::recv_initial_metadata
grpc_metadata_array * recv_initial_metadata
Definition: grpc_types.h:355
grpc::internal::CallOpRecvInitialMetadata::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:753
grpc::internal::InterceptorBatchMethodsImpl::SetRecvTrailingMetadata
void SetRecvTrailingMetadata(MetadataMap *map)
Definition: interceptor_common.h:180
grpc::internal::CallOpGenericRecvMessage::AllowNoMessage
void AllowNoMessage()
Definition: call_op_set.h:542
grpc::internal::InterceptorBatchMethodsImpl::SetSendInitialMetadata
void SetSendInitialMetadata(std::multimap< std::string, std::string > *metadata)
Definition: interceptor_common.h:152
grpc::internal::CallOpServerSendStatus::FinishOp
void FinishOp(bool *)
Definition: call_op_set.h:690
grpc::protobuf::util::Status
::absl::Status Status
Definition: config_protobuf.h:107
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:949
grpc::internal::CallOpSendInitialMetadata::is_set
bool is_set
Definition: call_op_set.h:284
grpc_call_start_batch
GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops, size_t nops, void *tag, void *reserved)
Start a batch of operations defined in the array ops; when complete, post a completion of type 'tag' ...
grpc::internal::CallOpSendMessage::SetFinishInterceptionHookPoint
void SetFinishInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:364
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:122
grpc::internal::InterceptorBatchMethodsImpl::SetSendTrailingMetadata
void SetSendTrailingMetadata(std::multimap< std::string, std::string > *metadata)
Definition: interceptor_common.h:164
grpc::internal::CallOpRecvMessage::RecvMessage
void RecvMessage(R *message)
Definition: call_op_set.h:431
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:212
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:277
string_ref.h
grpc::WriteOptions::clear_buffer_hint
WriteOptions & clear_buffer_hint()
Clears flag indicating that the write may be buffered and need not go out on the wire immediately.
Definition: call_op_set.h: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:709
grpc::internal::CallOpRecvMessage::AllowNoMessage
void AllowNoMessage()
Definition: call_op_set.h:434
grpc::SliceReferencingString
grpc_slice SliceReferencingString(const std::string &str)
Definition: slice.h:132
grpc::internal::CallOpSet::ContinueFinalizeResultAfterInterception
void ContinueFinalizeResultAfterInterception() override
Definition: call_op_set.h:989
grpc::internal::CallOpSendMessage::SetInterceptionHookPoint
void SetInterceptionHookPoint(InterceptorBatchMethodsImpl *interceptor_methods)
Definition: call_op_set.h:355
grpc::experimental::InterceptionHookPoints::PRE_RECV_INITIAL_METADATA
@ PRE_RECV_INITIAL_METADATA
The following three are for hijacked clients only.