GRPC C++  1.66.0
interceptor_common.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_INTERCEPTOR_COMMON_H
20 #define GRPCPP_IMPL_INTERCEPTOR_COMMON_H
21 
22 #include <array>
23 #include <functional>
24 
25 #include "absl/log/absl_check.h"
26 
27 #include <grpc/impl/grpc_types.h>
28 #include <grpc/support/log.h>
29 #include <grpcpp/impl/call.h>
34 
35 namespace grpc {
36 namespace internal {
37 
40  public:
42  for (auto i = static_cast<experimental::InterceptionHookPoints>(0);
44  i = static_cast<experimental::InterceptionHookPoints>(
45  static_cast<size_t>(i) + 1)) {
46  hooks_[static_cast<size_t>(i)] = false;
47  }
48  }
49 
51 
54  return hooks_[static_cast<size_t>(type)];
55  }
56 
57  void Proceed() override {
58  if (call_->client_rpc_info() != nullptr) {
59  return ProceedClient();
60  }
61  ABSL_CHECK_NE(call_->server_rpc_info(), nullptr);
62  ProceedServer();
63  }
64 
65  void Hijack() override {
66  // Only the client can hijack when sending down initial metadata
67  ABSL_CHECK(!reverse_ && ops_ != nullptr &&
68  call_->client_rpc_info() != nullptr);
69  // It is illegal to call Hijack twice
70  ABSL_CHECK(!ran_hijacking_interceptor_);
71  auto* rpc_info = call_->client_rpc_info();
72  rpc_info->hijacked_ = true;
73  rpc_info->hijacked_interceptor_ = current_interceptor_index_;
74  ClearHookPoints();
75  ops_->SetHijackingState();
76  ran_hijacking_interceptor_ = true;
77  rpc_info->RunInterceptor(this, current_interceptor_index_);
78  }
79 
81  hooks_[static_cast<size_t>(type)] = true;
82  }
83 
85  ABSL_CHECK_NE(orig_send_message_, nullptr);
86  if (*orig_send_message_ != nullptr) {
87  ABSL_CHECK(serializer_(*orig_send_message_).ok());
88  *orig_send_message_ = nullptr;
89  }
90  return send_message_;
91  }
92 
93  const void* GetSendMessage() override {
94  ABSL_CHECK_NE(orig_send_message_, nullptr);
95  return *orig_send_message_;
96  }
97 
98  void ModifySendMessage(const void* message) override {
99  ABSL_CHECK_NE(orig_send_message_, nullptr);
100  *orig_send_message_ = message;
101  }
102 
103  bool GetSendMessageStatus() override { return !*fail_send_message_; }
104 
105  std::multimap<std::string, std::string>* GetSendInitialMetadata() override {
106  return send_initial_metadata_;
107  }
108 
109  Status GetSendStatus() override {
110  return Status(static_cast<StatusCode>(*code_), *error_message_,
111  *error_details_);
112  }
113 
114  void ModifySendStatus(const Status& status) override {
115  *code_ = static_cast<grpc_status_code>(status.error_code());
116  *error_details_ = status.error_details();
117  *error_message_ = status.error_message();
118  }
119 
120  std::multimap<std::string, std::string>* GetSendTrailingMetadata() override {
121  return send_trailing_metadata_;
122  }
123 
124  void* GetRecvMessage() override { return recv_message_; }
125 
126  std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvInitialMetadata()
127  override {
128  return recv_initial_metadata_->map();
129  }
130 
131  Status* GetRecvStatus() override { return recv_status_; }
132 
133  void FailHijackedSendMessage() override {
134  ABSL_CHECK(hooks_[static_cast<size_t>(
136  *fail_send_message_ = true;
137  }
138 
139  std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata()
140  override {
141  return recv_trailing_metadata_->map();
142  }
143 
144  void SetSendMessage(ByteBuffer* buf, const void** msg,
145  bool* fail_send_message,
146  std::function<Status(const void*)> serializer) {
147  send_message_ = buf;
148  orig_send_message_ = msg;
149  fail_send_message_ = fail_send_message;
150  serializer_ = serializer;
151  }
152 
154  std::multimap<std::string, std::string>* metadata) {
155  send_initial_metadata_ = metadata;
156  }
157 
158  void SetSendStatus(grpc_status_code* code, std::string* error_details,
159  std::string* error_message) {
160  code_ = code;
161  error_details_ = error_details;
162  error_message_ = error_message;
163  }
164 
166  std::multimap<std::string, std::string>* metadata) {
167  send_trailing_metadata_ = metadata;
168  }
169 
170  void SetRecvMessage(void* message, bool* hijacked_recv_message_failed) {
171  recv_message_ = message;
172  hijacked_recv_message_failed_ = hijacked_recv_message_failed;
173  }
174 
176  recv_initial_metadata_ = map;
177  }
178 
179  void SetRecvStatus(Status* status) { recv_status_ = status; }
180 
182  recv_trailing_metadata_ = map;
183  }
184 
185  std::unique_ptr<ChannelInterface> GetInterceptedChannel() override {
186  auto* info = call_->client_rpc_info();
187  if (info == nullptr) {
188  return std::unique_ptr<ChannelInterface>(nullptr);
189  }
190  // The intercepted channel starts from the interceptor just after the
191  // current interceptor
192  return std::unique_ptr<ChannelInterface>(new InterceptedChannel(
193  info->channel(), current_interceptor_index_ + 1));
194  }
195 
196  void FailHijackedRecvMessage() override {
197  ABSL_CHECK(hooks_[static_cast<size_t>(
199  *hijacked_recv_message_failed_ = true;
200  }
201 
202  // Clears all state
203  void ClearState() {
204  reverse_ = false;
205  ran_hijacking_interceptor_ = false;
206  ClearHookPoints();
207  }
208 
209  // Prepares for Post_recv operations
210  void SetReverse() {
211  reverse_ = true;
212  ran_hijacking_interceptor_ = false;
213  ClearHookPoints();
214  }
215 
216  // This needs to be set before interceptors are run
217  void SetCall(Call* call) { call_ = call; }
218 
219  // This needs to be set before interceptors are run using RunInterceptors().
220  // Alternatively, RunInterceptors(std::function<void(void)> f) can be used.
221  void SetCallOpSetInterface(CallOpSetInterface* ops) { ops_ = ops; }
222 
223  // SetCall should have been called before this.
224  // Returns true if the interceptors list is empty
226  auto* client_rpc_info = call_->client_rpc_info();
227  if (client_rpc_info != nullptr) {
228  return client_rpc_info->interceptors_.empty();
229  }
230 
231  auto* server_rpc_info = call_->server_rpc_info();
232  return server_rpc_info == nullptr || server_rpc_info->interceptors_.empty();
233  }
234 
235  // This should be used only by subclasses of CallOpSetInterface. SetCall and
236  // SetCallOpSetInterface should have been called before this. After all the
237  // interceptors are done running, either ContinueFillOpsAfterInterception or
238  // ContinueFinalizeOpsAfterInterception will be called. Note that neither of
239  // them is invoked if there were no interceptors registered.
241  ABSL_CHECK(ops_);
242  auto* client_rpc_info = call_->client_rpc_info();
243  if (client_rpc_info != nullptr) {
244  if (client_rpc_info->interceptors_.empty()) {
245  return true;
246  } else {
247  RunClientInterceptors();
248  return false;
249  }
250  }
251 
252  auto* server_rpc_info = call_->server_rpc_info();
253  if (server_rpc_info == nullptr || server_rpc_info->interceptors_.empty()) {
254  return true;
255  }
256  RunServerInterceptors();
257  return false;
258  }
259 
260  // Returns true if no interceptors are run. Returns false otherwise if there
261  // are interceptors registered. After the interceptors are done running \a f
262  // will be invoked. This is to be used only by BaseAsyncRequest and
263  // SyncRequest.
264  bool RunInterceptors(std::function<void(void)> f) {
265  // This is used only by the server for initial call request
266  ABSL_CHECK_EQ(reverse_, true);
267  ABSL_CHECK_EQ(call_->client_rpc_info(), nullptr);
268  auto* server_rpc_info = call_->server_rpc_info();
269  if (server_rpc_info == nullptr || server_rpc_info->interceptors_.empty()) {
270  return true;
271  }
272  callback_ = std::move(f);
273  RunServerInterceptors();
274  return false;
275  }
276 
277  private:
278  void RunClientInterceptors() {
279  auto* rpc_info = call_->client_rpc_info();
280  if (!reverse_) {
281  current_interceptor_index_ = 0;
282  } else {
283  if (rpc_info->hijacked_) {
284  current_interceptor_index_ = rpc_info->hijacked_interceptor_;
285  } else {
286  current_interceptor_index_ = rpc_info->interceptors_.size() - 1;
287  }
288  }
289  rpc_info->RunInterceptor(this, current_interceptor_index_);
290  }
291 
292  void RunServerInterceptors() {
293  auto* rpc_info = call_->server_rpc_info();
294  if (!reverse_) {
295  current_interceptor_index_ = 0;
296  } else {
297  current_interceptor_index_ = rpc_info->interceptors_.size() - 1;
298  }
299  rpc_info->RunInterceptor(this, current_interceptor_index_);
300  }
301 
302  void ProceedClient() {
303  auto* rpc_info = call_->client_rpc_info();
304  if (rpc_info->hijacked_ && !reverse_ &&
305  current_interceptor_index_ == rpc_info->hijacked_interceptor_ &&
306  !ran_hijacking_interceptor_) {
307  // We now need to provide hijacked recv ops to this interceptor
308  ClearHookPoints();
309  ops_->SetHijackingState();
310  ran_hijacking_interceptor_ = true;
311  rpc_info->RunInterceptor(this, current_interceptor_index_);
312  return;
313  }
314  if (!reverse_) {
315  current_interceptor_index_++;
316  // We are going down the stack of interceptors
317  if (current_interceptor_index_ < rpc_info->interceptors_.size()) {
318  if (rpc_info->hijacked_ &&
319  current_interceptor_index_ > rpc_info->hijacked_interceptor_) {
320  // This is a hijacked RPC and we are done with hijacking
322  } else {
323  rpc_info->RunInterceptor(this, current_interceptor_index_);
324  }
325  } else {
326  // we are done running all the interceptors without any hijacking
328  }
329  } else {
330  // We are going up the stack of interceptors
331  if (current_interceptor_index_ > 0) {
332  // Continue running interceptors
333  current_interceptor_index_--;
334  rpc_info->RunInterceptor(this, current_interceptor_index_);
335  } else {
336  // we are done running all the interceptors without any hijacking
338  }
339  }
340  }
341 
342  void ProceedServer() {
343  auto* rpc_info = call_->server_rpc_info();
344  if (!reverse_) {
345  current_interceptor_index_++;
346  if (current_interceptor_index_ < rpc_info->interceptors_.size()) {
347  return rpc_info->RunInterceptor(this, current_interceptor_index_);
348  } else if (ops_) {
349  return ops_->ContinueFillOpsAfterInterception();
350  }
351  } else {
352  // We are going up the stack of interceptors
353  if (current_interceptor_index_ > 0) {
354  // Continue running interceptors
355  current_interceptor_index_--;
356  return rpc_info->RunInterceptor(this, current_interceptor_index_);
357  } else if (ops_) {
359  }
360  }
361  ABSL_CHECK(callback_);
362  callback_();
363  }
364 
365  void ClearHookPoints() {
366  for (auto i = static_cast<experimental::InterceptionHookPoints>(0);
368  i = static_cast<experimental::InterceptionHookPoints>(
369  static_cast<size_t>(i) + 1)) {
370  hooks_[static_cast<size_t>(i)] = false;
371  }
372  }
373 
374  std::array<bool,
375  static_cast<size_t>(
377  hooks_;
378 
379  size_t current_interceptor_index_ = 0; // Current iterator
380  bool reverse_ = false;
381  bool ran_hijacking_interceptor_ = false;
382  Call* call_ = nullptr; // The Call object is present along with CallOpSet
383  // object/callback
384  CallOpSetInterface* ops_ = nullptr;
385  std::function<void(void)> callback_;
386 
387  ByteBuffer* send_message_ = nullptr;
388  bool* fail_send_message_ = nullptr;
389  const void** orig_send_message_ = nullptr;
390  std::function<Status(const void*)> serializer_;
391 
392  std::multimap<std::string, std::string>* send_initial_metadata_;
393 
394  grpc_status_code* code_ = nullptr;
395  std::string* error_details_ = nullptr;
396  std::string* error_message_ = nullptr;
397 
398  std::multimap<std::string, std::string>* send_trailing_metadata_ = nullptr;
399 
400  void* recv_message_ = nullptr;
401  bool* hijacked_recv_message_failed_ = nullptr;
402 
403  MetadataMap* recv_initial_metadata_ = nullptr;
404 
405  Status* recv_status_ = nullptr;
406 
407  MetadataMap* recv_trailing_metadata_ = nullptr;
408 };
409 
410 // A special implementation of InterceptorBatchMethods to send a Cancel
411 // notification down the interceptor stack
414  public:
416  experimental::InterceptionHookPoints type) override {
418  }
419 
420  void Proceed() override {
421  // This is a no-op. For actual continuation of the RPC simply needs to
422  // return from the Intercept method
423  }
424 
425  void Hijack() override {
426  // Only the client can hijack when sending down initial metadata
427  ABSL_CHECK(false) << "It is illegal to call Hijack on a method which has a "
428  "Cancel notification";
429  }
430 
432  ABSL_CHECK(false)
433  << "It is illegal to call GetSendMessage on a method which "
434  "has a Cancel notification";
435  return nullptr;
436  }
437 
438  bool GetSendMessageStatus() override {
439  ABSL_CHECK(false)
440  << "It is illegal to call GetSendMessageStatus on a method which "
441  "has a Cancel notification";
442  return false;
443  }
444 
445  const void* GetSendMessage() override {
446  ABSL_CHECK(false)
447  << "It is illegal to call GetOriginalSendMessage on a method which "
448  "has a Cancel notification";
449  return nullptr;
450  }
451 
452  void ModifySendMessage(const void* /*message*/) override {
453  ABSL_CHECK(false)
454  << "It is illegal to call ModifySendMessage on a method which "
455  "has a Cancel notification";
456  }
457 
458  std::multimap<std::string, std::string>* GetSendInitialMetadata() override {
459  ABSL_CHECK(false) << "It is illegal to call GetSendInitialMetadata on a "
460  "method which has a Cancel notification";
461  return nullptr;
462  }
463 
464  Status GetSendStatus() override {
465  ABSL_CHECK(false)
466  << "It is illegal to call GetSendStatus on a method which "
467  "has a Cancel notification";
468  return Status();
469  }
470 
471  void ModifySendStatus(const Status& /*status*/) override {
472  ABSL_CHECK(false) << "It is illegal to call ModifySendStatus on a method "
473  "which has a Cancel notification";
474  }
475 
476  std::multimap<std::string, std::string>* GetSendTrailingMetadata() override {
477  ABSL_CHECK(false) << "It is illegal to call GetSendTrailingMetadata on a "
478  "method which has a Cancel notification";
479  return nullptr;
480  }
481 
482  void* GetRecvMessage() override {
483  ABSL_CHECK(false)
484  << "It is illegal to call GetRecvMessage on a method which "
485  "has a Cancel notification";
486  return nullptr;
487  }
488 
489  std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvInitialMetadata()
490  override {
491  ABSL_CHECK(false) << "It is illegal to call GetRecvInitialMetadata on a "
492  "method which has a Cancel notification";
493  return nullptr;
494  }
495 
496  Status* GetRecvStatus() override {
497  ABSL_CHECK(false)
498  << "It is illegal to call GetRecvStatus on a method which "
499  "has a Cancel notification";
500  return nullptr;
501  }
502 
503  std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata()
504  override {
505  ABSL_CHECK(false) << "It is illegal to call GetRecvTrailingMetadata on a "
506  "method which has a Cancel notification";
507  return nullptr;
508  }
509 
510  std::unique_ptr<ChannelInterface> GetInterceptedChannel() override {
511  ABSL_CHECK(false) << "It is illegal to call GetInterceptedChannel on a "
512  "method which has a Cancel notification";
513  return std::unique_ptr<ChannelInterface>(nullptr);
514  }
515 
516  void FailHijackedRecvMessage() override {
517  ABSL_CHECK(false) << "It is illegal to call FailHijackedRecvMessage on a "
518  "method which has a Cancel notification";
519  }
520 
521  void FailHijackedSendMessage() override {
522  ABSL_CHECK(false) << "It is illegal to call FailHijackedSendMessage on a "
523  "method which has a Cancel notification";
524  }
525 };
526 } // namespace internal
527 } // namespace grpc
528 
529 #endif // GRPCPP_IMPL_INTERCEPTOR_COMMON_H
grpc::internal::InterceptorBatchMethodsImpl::GetSerializedSendMessage
ByteBuffer * GetSerializedSendMessage() override
Send Message Methods GetSerializedSendMessage and GetSendMessage/ModifySendMessage are the available ...
Definition: interceptor_common.h:84
grpc::internal::InterceptorBatchMethodsImpl::Proceed
void Proceed() override
Signal that the interceptor is done intercepting the current batch of the RPC.
Definition: interceptor_common.h:57
grpc::internal::InterceptorBatchMethodsImpl::ModifySendStatus
void ModifySendStatus(const Status &status) override
Overwrites the status with status.
Definition: interceptor_common.h:114
grpc::internal::CancelInterceptorBatchMethods::GetSendTrailingMetadata
std::multimap< std::string, std::string > * GetSendTrailingMetadata() override
Returns a modifiable multimap of the trailing metadata to be sent.
Definition: interceptor_common.h:476
grpc::internal::CancelInterceptorBatchMethods::ModifySendMessage
void ModifySendMessage(const void *) override
Overwrites the message to be sent with message.
Definition: interceptor_common.h:452
grpc::internal::InterceptorBatchMethodsImpl::GetSendStatus
Status GetSendStatus() override
Returns the status to be sent. Valid for PRE_SEND_STATUS interceptions.
Definition: interceptor_common.h:109
grpc::internal::CallOpSetInterface::SetHijackingState
virtual void SetHijackingState()=0
grpc::internal::InterceptorBatchMethodsImpl::QueryInterceptionHookPoint
bool QueryInterceptionHookPoint(experimental::InterceptionHookPoints type) override
Determine whether the current batch has an interception hook point of type type.
Definition: interceptor_common.h:52
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc::internal::InterceptorBatchMethodsImpl::ModifySendMessage
void ModifySendMessage(const void *message) override
Overwrites the message to be sent with message.
Definition: interceptor_common.h:98
grpc_status_code
grpc_status_code
Definition: status.h:28
grpc::internal::InterceptorBatchMethodsImpl::SetRecvInitialMetadata
void SetRecvInitialMetadata(MetadataMap *map)
Definition: interceptor_common.h:175
grpc::internal::CancelInterceptorBatchMethods::GetSendStatus
Status GetSendStatus() override
Returns the status to be sent. Valid for PRE_SEND_STATUS interceptions.
Definition: interceptor_common.h:464
grpc::internal::InterceptorBatchMethodsImpl::SetCallOpSetInterface
void SetCallOpSetInterface(CallOpSetInterface *ops)
Definition: interceptor_common.h:221
grpc::experimental::InterceptionHookPoints::PRE_RECV_MESSAGE
@ PRE_RECV_MESSAGE
grpc::internal::InterceptorBatchMethodsImpl::GetRecvInitialMetadata
std::multimap< grpc::string_ref, grpc::string_ref > * GetRecvInitialMetadata() override
Returns a modifiable multimap of the received initial metadata.
Definition: interceptor_common.h:126
grpc::internal::InterceptorBatchMethodsImpl::SetCall
void SetCall(Call *call)
Definition: interceptor_common.h:217
grpc::internal::InterceptorBatchMethodsImpl::InterceptorsListEmpty
bool InterceptorsListEmpty()
Definition: interceptor_common.h:225
grpc::internal::InterceptorBatchMethodsImpl::InterceptorBatchMethodsImpl
InterceptorBatchMethodsImpl()
Definition: interceptor_common.h:41
grpc::internal::CancelInterceptorBatchMethods::FailHijackedRecvMessage
void FailHijackedRecvMessage() override
On a hijacked RPC, an interceptor can decide to fail a PRE_RECV_MESSAGE op.
Definition: interceptor_common.h:516
grpc::internal::InterceptorBatchMethodsImpl::ClearState
void ClearState()
Definition: interceptor_common.h:203
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:36
grpc::internal::InterceptorBatchMethodsImpl::FailHijackedSendMessage
void FailHijackedSendMessage() override
On a hijacked RPC/ to-be hijacked RPC, this can be called to fail a SEND MESSAGE op.
Definition: interceptor_common.h:133
grpc::internal::MetadataMap
Definition: metadata_map.h:34
grpc::experimental::InterceptionHookPoints::PRE_SEND_CANCEL
@ PRE_SEND_CANCEL
This is a special hook point available to both clients and servers when TryCancel() is performed.
grpc_types.h
grpc::internal::MetadataMap::map
std::multimap< grpc::string_ref, grpc::string_ref > * map()
Definition: metadata_map.h:67
grpc::internal::InterceptorBatchMethodsImpl::GetSendMessageStatus
bool GetSendMessageStatus() override
Checks whether the SEND MESSAGE op succeeded.
Definition: interceptor_common.h:103
grpc::internal::CancelInterceptorBatchMethods::GetInterceptedChannel
std::unique_ptr< ChannelInterface > GetInterceptedChannel() override
Gets an intercepted channel.
Definition: interceptor_common.h:510
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:34
client_interceptor.h
grpc::internal::InterceptorBatchMethodsImpl::SetSendStatus
void SetSendStatus(grpc_status_code *code, std::string *error_details, std::string *error_message)
Definition: interceptor_common.h:158
grpc::internal::CancelInterceptorBatchMethods::GetRecvMessage
void * GetRecvMessage() override
Returns a pointer to the modifiable received message.
Definition: interceptor_common.h:482
log.h
grpc::internal::InterceptorBatchMethodsImpl::RunInterceptors
bool RunInterceptors(std::function< void(void)> f)
Definition: interceptor_common.h:264
grpc::internal::InterceptorBatchMethodsImpl::GetSendTrailingMetadata
std::multimap< std::string, std::string > * GetSendTrailingMetadata() override
Returns a modifiable multimap of the trailing metadata to be sent.
Definition: interceptor_common.h:120
grpc::internal::CancelInterceptorBatchMethods::GetSendMessage
const void * GetSendMessage() override
Returns a non-modifiable pointer to the non-serialized form of the message to be sent.
Definition: interceptor_common.h:445
grpc::internal::CallOpSetInterface
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call_op_set_interface.h:36
grpc::ByteBuffer
A sequence of bytes.
Definition: byte_buffer.h:60
grpc::internal::InterceptorBatchMethodsImpl::SetReverse
void SetReverse()
Definition: interceptor_common.h:210
grpc::internal::InterceptorBatchMethodsImpl::SetRecvStatus
void SetRecvStatus(Status *status)
Definition: interceptor_common.h:179
grpc::internal::InterceptorBatchMethodsImpl::GetRecvMessage
void * GetRecvMessage() override
Returns a pointer to the modifiable received message.
Definition: interceptor_common.h:124
grpc::internal::CancelInterceptorBatchMethods::GetRecvInitialMetadata
std::multimap< grpc::string_ref, grpc::string_ref > * GetRecvInitialMetadata() override
Returns a modifiable multimap of the received initial metadata.
Definition: interceptor_common.h:489
grpc::internal::CancelInterceptorBatchMethods::ModifySendStatus
void ModifySendStatus(const Status &) override
Overwrites the status with status.
Definition: interceptor_common.h:471
grpc::internal::InterceptorBatchMethodsImpl::Hijack
void Hijack() override
Indicate that the interceptor has hijacked the RPC (only valid if the batch contains send_initial_met...
Definition: interceptor_common.h:65
grpc::internal::InterceptedChannel
An InterceptedChannel is available to client Interceptors.
Definition: intercepted_channel.h:35
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::CancelInterceptorBatchMethods::GetSerializedSendMessage
ByteBuffer * GetSerializedSendMessage() override
Send Message Methods GetSerializedSendMessage and GetSendMessage/ModifySendMessage are the available ...
Definition: interceptor_common.h:431
call_op_set_interface.h
grpc::internal::InterceptorBatchMethodsImpl::GetSendInitialMetadata
std::multimap< std::string, std::string > * GetSendInitialMetadata() override
Returns a modifiable multimap of the initial metadata to be sent.
Definition: interceptor_common.h:105
server_interceptor.h
grpc::internal::InterceptorBatchMethodsImpl::GetSendMessage
const void * GetSendMessage() override
Returns a non-modifiable pointer to the non-serialized form of the message to be sent.
Definition: interceptor_common.h:93
grpc::experimental::InterceptionHookPoints::NUM_INTERCEPTION_HOOKS
@ NUM_INTERCEPTION_HOOKS
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:170
grpc::Status::error_code
StatusCode error_code() const
Return the instance's error code.
Definition: status.h:117
grpc::internal::CancelInterceptorBatchMethods::GetRecvStatus
Status * GetRecvStatus() override
Returns a modifiable view of the received status on PRE_RECV_STATUS and POST_RECV_STATUS interception...
Definition: interceptor_common.h:496
grpc::internal::CancelInterceptorBatchMethods::Hijack
void Hijack() override
Indicate that the interceptor has hijacked the RPC (only valid if the batch contains send_initial_met...
Definition: interceptor_common.h:425
grpc::internal::InterceptorBatchMethodsImpl::FailHijackedRecvMessage
void FailHijackedRecvMessage() override
On a hijacked RPC, an interceptor can decide to fail a PRE_RECV_MESSAGE op.
Definition: interceptor_common.h:196
grpc::internal::Call::server_rpc_info
experimental::ServerRpcInfo * server_rpc_info() const
Definition: call.h:79
grpc::internal::InterceptorBatchMethodsImpl::GetRecvTrailingMetadata
std::multimap< grpc::string_ref, grpc::string_ref > * GetRecvTrailingMetadata() override
Returns a modifiable multimap of the received trailing metadata on PRE_RECV_STATUS and POST_RECV_STAT...
Definition: interceptor_common.h:139
grpc::internal::CallOpSetInterface::ContinueFillOpsAfterInterception
virtual void ContinueFillOpsAfterInterception()=0
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:144
grpc::internal::InterceptorBatchMethodsImpl::~InterceptorBatchMethodsImpl
~InterceptorBatchMethodsImpl() override
Definition: interceptor_common.h:50
grpc::internal::CallOpSetInterface::ContinueFinalizeResultAfterInterception
virtual void ContinueFinalizeResultAfterInterception()=0
grpc::internal::InterceptorBatchMethodsImpl::GetRecvStatus
Status * GetRecvStatus() override
Returns a modifiable view of the received status on PRE_RECV_STATUS and POST_RECV_STATUS interception...
Definition: interceptor_common.h:131
call.h
grpc::internal::InterceptorBatchMethodsImpl::GetInterceptedChannel
std::unique_ptr< ChannelInterface > GetInterceptedChannel() override
Gets an intercepted channel.
Definition: interceptor_common.h:185
grpc::experimental::InterceptorBatchMethods
Class that is passed as an argument to the Intercept method of the application's Interceptor interfac...
Definition: interceptor.h:95
grpc::internal::CancelInterceptorBatchMethods::Proceed
void Proceed() override
Signal that the interceptor is done intercepting the current batch of the RPC.
Definition: interceptor_common.h:420
grpc::internal::CancelInterceptorBatchMethods::GetSendMessageStatus
bool GetSendMessageStatus() override
Checks whether the SEND MESSAGE op succeeded.
Definition: interceptor_common.h:438
intercepted_channel.h
grpc::internal::InterceptorBatchMethodsImpl::RunInterceptors
bool RunInterceptors()
Definition: interceptor_common.h:240
grpc::internal::CancelInterceptorBatchMethods::FailHijackedSendMessage
void FailHijackedSendMessage() override
On a hijacked RPC/ to-be hijacked RPC, this can be called to fail a SEND MESSAGE op.
Definition: interceptor_common.h:521
grpc::internal::CancelInterceptorBatchMethods
Definition: interceptor_common.h:412
grpc::internal::InterceptorBatchMethodsImpl::SetRecvTrailingMetadata
void SetRecvTrailingMetadata(MetadataMap *map)
Definition: interceptor_common.h:181
grpc::internal::InterceptorBatchMethodsImpl::SetSendInitialMetadata
void SetSendInitialMetadata(std::multimap< std::string, std::string > *metadata)
Definition: interceptor_common.h:153
grpc::protobuf::util::Status
::absl::Status Status
Definition: config_protobuf.h:106
grpc::internal::CancelInterceptorBatchMethods::QueryInterceptionHookPoint
bool QueryInterceptionHookPoint(experimental::InterceptionHookPoints type) override
Determine whether the current batch has an interception hook point of type type.
Definition: interceptor_common.h:415
grpc::experimental::InterceptionHookPoints
InterceptionHookPoints
An enumeration of different possible points at which the Intercept method of the Interceptor interfac...
Definition: interceptor.h:56
grpc::internal::InterceptorBatchMethodsImpl
Definition: interceptor_common.h:38
grpc::Status::error_details
std::string error_details() const
Return the (binary) error details.
Definition: status.h:122
grpc::internal::InterceptorBatchMethodsImpl::SetSendTrailingMetadata
void SetSendTrailingMetadata(std::multimap< std::string, std::string > *metadata)
Definition: interceptor_common.h:165
grpc::internal::CancelInterceptorBatchMethods::GetSendInitialMetadata
std::multimap< std::string, std::string > * GetSendInitialMetadata() override
Returns a modifiable multimap of the initial metadata to be sent.
Definition: interceptor_common.h:458
grpc::internal::InterceptorBatchMethodsImpl::AddInterceptionHookPoint
void AddInterceptionHookPoint(experimental::InterceptionHookPoints type)
Definition: interceptor_common.h:80
grpc::internal::Call::client_rpc_info
experimental::ClientRpcInfo * client_rpc_info() const
Definition: call.h:75
grpc::internal::CancelInterceptorBatchMethods::GetRecvTrailingMetadata
std::multimap< grpc::string_ref, grpc::string_ref > * GetRecvTrailingMetadata() override
Returns a modifiable multimap of the received trailing metadata on PRE_RECV_STATUS and POST_RECV_STAT...
Definition: interceptor_common.h:503