GRPC C++  1.64.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/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  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  CHECK(!reverse_ && ops_ != nullptr && call_->client_rpc_info() != nullptr);
68  // It is illegal to call Hijack twice
69  CHECK(!ran_hijacking_interceptor_);
70  auto* rpc_info = call_->client_rpc_info();
71  rpc_info->hijacked_ = true;
72  rpc_info->hijacked_interceptor_ = current_interceptor_index_;
73  ClearHookPoints();
74  ops_->SetHijackingState();
75  ran_hijacking_interceptor_ = true;
76  rpc_info->RunInterceptor(this, current_interceptor_index_);
77  }
78 
80  hooks_[static_cast<size_t>(type)] = true;
81  }
82 
84  CHECK_NE(orig_send_message_, nullptr);
85  if (*orig_send_message_ != nullptr) {
86  CHECK(serializer_(*orig_send_message_).ok());
87  *orig_send_message_ = nullptr;
88  }
89  return send_message_;
90  }
91 
92  const void* GetSendMessage() override {
93  CHECK_NE(orig_send_message_, nullptr);
94  return *orig_send_message_;
95  }
96 
97  void ModifySendMessage(const void* message) override {
98  CHECK_NE(orig_send_message_, nullptr);
99  *orig_send_message_ = message;
100  }
101 
102  bool GetSendMessageStatus() override { return !*fail_send_message_; }
103 
104  std::multimap<std::string, std::string>* GetSendInitialMetadata() override {
105  return send_initial_metadata_;
106  }
107 
108  Status GetSendStatus() override {
109  return Status(static_cast<StatusCode>(*code_), *error_message_,
110  *error_details_);
111  }
112 
113  void ModifySendStatus(const Status& status) override {
114  *code_ = static_cast<grpc_status_code>(status.error_code());
115  *error_details_ = status.error_details();
116  *error_message_ = status.error_message();
117  }
118 
119  std::multimap<std::string, std::string>* GetSendTrailingMetadata() override {
120  return send_trailing_metadata_;
121  }
122 
123  void* GetRecvMessage() override { return recv_message_; }
124 
125  std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvInitialMetadata()
126  override {
127  return recv_initial_metadata_->map();
128  }
129 
130  Status* GetRecvStatus() override { return recv_status_; }
131 
132  void FailHijackedSendMessage() override {
133  CHECK(hooks_[static_cast<size_t>(
135  *fail_send_message_ = true;
136  }
137 
138  std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata()
139  override {
140  return recv_trailing_metadata_->map();
141  }
142 
143  void SetSendMessage(ByteBuffer* buf, const void** msg,
144  bool* fail_send_message,
145  std::function<Status(const void*)> serializer) {
146  send_message_ = buf;
147  orig_send_message_ = msg;
148  fail_send_message_ = fail_send_message;
149  serializer_ = serializer;
150  }
151 
153  std::multimap<std::string, std::string>* metadata) {
154  send_initial_metadata_ = metadata;
155  }
156 
157  void SetSendStatus(grpc_status_code* code, std::string* error_details,
158  std::string* error_message) {
159  code_ = code;
160  error_details_ = error_details;
161  error_message_ = error_message;
162  }
163 
165  std::multimap<std::string, std::string>* metadata) {
166  send_trailing_metadata_ = metadata;
167  }
168 
169  void SetRecvMessage(void* message, bool* hijacked_recv_message_failed) {
170  recv_message_ = message;
171  hijacked_recv_message_failed_ = hijacked_recv_message_failed;
172  }
173 
175  recv_initial_metadata_ = map;
176  }
177 
178  void SetRecvStatus(Status* status) { recv_status_ = status; }
179 
181  recv_trailing_metadata_ = map;
182  }
183 
184  std::unique_ptr<ChannelInterface> GetInterceptedChannel() override {
185  auto* info = call_->client_rpc_info();
186  if (info == nullptr) {
187  return std::unique_ptr<ChannelInterface>(nullptr);
188  }
189  // The intercepted channel starts from the interceptor just after the
190  // current interceptor
191  return std::unique_ptr<ChannelInterface>(new InterceptedChannel(
192  info->channel(), current_interceptor_index_ + 1));
193  }
194 
195  void FailHijackedRecvMessage() override {
196  CHECK(hooks_[static_cast<size_t>(
198  *hijacked_recv_message_failed_ = true;
199  }
200 
201  // Clears all state
202  void ClearState() {
203  reverse_ = false;
204  ran_hijacking_interceptor_ = false;
205  ClearHookPoints();
206  }
207 
208  // Prepares for Post_recv operations
209  void SetReverse() {
210  reverse_ = true;
211  ran_hijacking_interceptor_ = false;
212  ClearHookPoints();
213  }
214 
215  // This needs to be set before interceptors are run
216  void SetCall(Call* call) { call_ = call; }
217 
218  // This needs to be set before interceptors are run using RunInterceptors().
219  // Alternatively, RunInterceptors(std::function<void(void)> f) can be used.
220  void SetCallOpSetInterface(CallOpSetInterface* ops) { ops_ = ops; }
221 
222  // SetCall should have been called before this.
223  // Returns true if the interceptors list is empty
225  auto* client_rpc_info = call_->client_rpc_info();
226  if (client_rpc_info != nullptr) {
227  return client_rpc_info->interceptors_.empty();
228  }
229 
230  auto* server_rpc_info = call_->server_rpc_info();
231  return server_rpc_info == nullptr || server_rpc_info->interceptors_.empty();
232  }
233 
234  // This should be used only by subclasses of CallOpSetInterface. SetCall and
235  // SetCallOpSetInterface should have been called before this. After all the
236  // interceptors are done running, either ContinueFillOpsAfterInterception or
237  // ContinueFinalizeOpsAfterInterception will be called. Note that neither of
238  // them is invoked if there were no interceptors registered.
240  CHECK(ops_);
241  auto* client_rpc_info = call_->client_rpc_info();
242  if (client_rpc_info != nullptr) {
243  if (client_rpc_info->interceptors_.empty()) {
244  return true;
245  } else {
246  RunClientInterceptors();
247  return false;
248  }
249  }
250 
251  auto* server_rpc_info = call_->server_rpc_info();
252  if (server_rpc_info == nullptr || server_rpc_info->interceptors_.empty()) {
253  return true;
254  }
255  RunServerInterceptors();
256  return false;
257  }
258 
259  // Returns true if no interceptors are run. Returns false otherwise if there
260  // are interceptors registered. After the interceptors are done running \a f
261  // will be invoked. This is to be used only by BaseAsyncRequest and
262  // SyncRequest.
263  bool RunInterceptors(std::function<void(void)> f) {
264  // This is used only by the server for initial call request
265  CHECK_EQ(reverse_, true);
266  CHECK_EQ(call_->client_rpc_info(), nullptr);
267  auto* server_rpc_info = call_->server_rpc_info();
268  if (server_rpc_info == nullptr || server_rpc_info->interceptors_.empty()) {
269  return true;
270  }
271  callback_ = std::move(f);
272  RunServerInterceptors();
273  return false;
274  }
275 
276  private:
277  void RunClientInterceptors() {
278  auto* rpc_info = call_->client_rpc_info();
279  if (!reverse_) {
280  current_interceptor_index_ = 0;
281  } else {
282  if (rpc_info->hijacked_) {
283  current_interceptor_index_ = rpc_info->hijacked_interceptor_;
284  } else {
285  current_interceptor_index_ = rpc_info->interceptors_.size() - 1;
286  }
287  }
288  rpc_info->RunInterceptor(this, current_interceptor_index_);
289  }
290 
291  void RunServerInterceptors() {
292  auto* rpc_info = call_->server_rpc_info();
293  if (!reverse_) {
294  current_interceptor_index_ = 0;
295  } else {
296  current_interceptor_index_ = rpc_info->interceptors_.size() - 1;
297  }
298  rpc_info->RunInterceptor(this, current_interceptor_index_);
299  }
300 
301  void ProceedClient() {
302  auto* rpc_info = call_->client_rpc_info();
303  if (rpc_info->hijacked_ && !reverse_ &&
304  current_interceptor_index_ == rpc_info->hijacked_interceptor_ &&
305  !ran_hijacking_interceptor_) {
306  // We now need to provide hijacked recv ops to this interceptor
307  ClearHookPoints();
308  ops_->SetHijackingState();
309  ran_hijacking_interceptor_ = true;
310  rpc_info->RunInterceptor(this, current_interceptor_index_);
311  return;
312  }
313  if (!reverse_) {
314  current_interceptor_index_++;
315  // We are going down the stack of interceptors
316  if (current_interceptor_index_ < rpc_info->interceptors_.size()) {
317  if (rpc_info->hijacked_ &&
318  current_interceptor_index_ > rpc_info->hijacked_interceptor_) {
319  // This is a hijacked RPC and we are done with hijacking
321  } else {
322  rpc_info->RunInterceptor(this, current_interceptor_index_);
323  }
324  } else {
325  // we are done running all the interceptors without any hijacking
327  }
328  } else {
329  // We are going up the stack of interceptors
330  if (current_interceptor_index_ > 0) {
331  // Continue running interceptors
332  current_interceptor_index_--;
333  rpc_info->RunInterceptor(this, current_interceptor_index_);
334  } else {
335  // we are done running all the interceptors without any hijacking
337  }
338  }
339  }
340 
341  void ProceedServer() {
342  auto* rpc_info = call_->server_rpc_info();
343  if (!reverse_) {
344  current_interceptor_index_++;
345  if (current_interceptor_index_ < rpc_info->interceptors_.size()) {
346  return rpc_info->RunInterceptor(this, current_interceptor_index_);
347  } else if (ops_) {
348  return ops_->ContinueFillOpsAfterInterception();
349  }
350  } else {
351  // We are going up the stack of interceptors
352  if (current_interceptor_index_ > 0) {
353  // Continue running interceptors
354  current_interceptor_index_--;
355  return rpc_info->RunInterceptor(this, current_interceptor_index_);
356  } else if (ops_) {
358  }
359  }
360  CHECK(callback_);
361  callback_();
362  }
363 
364  void ClearHookPoints() {
365  for (auto i = static_cast<experimental::InterceptionHookPoints>(0);
367  i = static_cast<experimental::InterceptionHookPoints>(
368  static_cast<size_t>(i) + 1)) {
369  hooks_[static_cast<size_t>(i)] = false;
370  }
371  }
372 
373  std::array<bool,
374  static_cast<size_t>(
376  hooks_;
377 
378  size_t current_interceptor_index_ = 0; // Current iterator
379  bool reverse_ = false;
380  bool ran_hijacking_interceptor_ = false;
381  Call* call_ = nullptr; // The Call object is present along with CallOpSet
382  // object/callback
383  CallOpSetInterface* ops_ = nullptr;
384  std::function<void(void)> callback_;
385 
386  ByteBuffer* send_message_ = nullptr;
387  bool* fail_send_message_ = nullptr;
388  const void** orig_send_message_ = nullptr;
389  std::function<Status(const void*)> serializer_;
390 
391  std::multimap<std::string, std::string>* send_initial_metadata_;
392 
393  grpc_status_code* code_ = nullptr;
394  std::string* error_details_ = nullptr;
395  std::string* error_message_ = nullptr;
396 
397  std::multimap<std::string, std::string>* send_trailing_metadata_ = nullptr;
398 
399  void* recv_message_ = nullptr;
400  bool* hijacked_recv_message_failed_ = nullptr;
401 
402  MetadataMap* recv_initial_metadata_ = nullptr;
403 
404  Status* recv_status_ = nullptr;
405 
406  MetadataMap* recv_trailing_metadata_ = nullptr;
407 };
408 
409 // A special implementation of InterceptorBatchMethods to send a Cancel
410 // notification down the interceptor stack
413  public:
415  experimental::InterceptionHookPoints type) override {
417  }
418 
419  void Proceed() override {
420  // This is a no-op. For actual continuation of the RPC simply needs to
421  // return from the Intercept method
422  }
423 
424  void Hijack() override {
425  // Only the client can hijack when sending down initial metadata
426  CHECK(false) << "It is illegal to call Hijack on a method which has a "
427  "Cancel notification";
428  }
429 
431  CHECK(false) << "It is illegal to call GetSendMessage on a method which "
432  "has a Cancel notification";
433  return nullptr;
434  }
435 
436  bool GetSendMessageStatus() override {
437  CHECK(false)
438  << "It is illegal to call GetSendMessageStatus on a method which "
439  "has a Cancel notification";
440  return false;
441  }
442 
443  const void* GetSendMessage() override {
444  CHECK(false)
445  << "It is illegal to call GetOriginalSendMessage on a method which "
446  "has a Cancel notification";
447  return nullptr;
448  }
449 
450  void ModifySendMessage(const void* /*message*/) override {
451  CHECK(false) << "It is illegal to call ModifySendMessage on a method which "
452  "has a Cancel notification";
453  }
454 
455  std::multimap<std::string, std::string>* GetSendInitialMetadata() override {
456  CHECK(false) << "It is illegal to call GetSendInitialMetadata on a "
457  "method which has a Cancel notification";
458  return nullptr;
459  }
460 
461  Status GetSendStatus() override {
462  CHECK(false) << "It is illegal to call GetSendStatus on a method which "
463  "has a Cancel notification";
464  return Status();
465  }
466 
467  void ModifySendStatus(const Status& /*status*/) override {
468  CHECK(false) << "It is illegal to call ModifySendStatus on a method "
469  "which has a Cancel notification";
470  }
471 
472  std::multimap<std::string, std::string>* GetSendTrailingMetadata() override {
473  CHECK(false) << "It is illegal to call GetSendTrailingMetadata on a "
474  "method which has a Cancel notification";
475  return nullptr;
476  }
477 
478  void* GetRecvMessage() override {
479  CHECK(false) << "It is illegal to call GetRecvMessage on a method which "
480  "has a Cancel notification";
481  return nullptr;
482  }
483 
484  std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvInitialMetadata()
485  override {
486  CHECK(false) << "It is illegal to call GetRecvInitialMetadata on a "
487  "method which has a Cancel notification";
488  return nullptr;
489  }
490 
491  Status* GetRecvStatus() override {
492  CHECK(false) << "It is illegal to call GetRecvStatus on a method which "
493  "has a Cancel notification";
494  return nullptr;
495  }
496 
497  std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata()
498  override {
499  CHECK(false) << "It is illegal to call GetRecvTrailingMetadata on a "
500  "method which has a Cancel notification";
501  return nullptr;
502  }
503 
504  std::unique_ptr<ChannelInterface> GetInterceptedChannel() override {
505  CHECK(false) << "It is illegal to call GetInterceptedChannel on a "
506  "method which has a Cancel notification";
507  return std::unique_ptr<ChannelInterface>(nullptr);
508  }
509 
510  void FailHijackedRecvMessage() override {
511  CHECK(false) << "It is illegal to call FailHijackedRecvMessage on a "
512  "method which has a Cancel notification";
513  }
514 
515  void FailHijackedSendMessage() override {
516  CHECK(false) << "It is illegal to call FailHijackedSendMessage on a "
517  "method which has a Cancel notification";
518  }
519 };
520 } // namespace internal
521 } // namespace grpc
522 
523 #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:83
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:113
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:472
grpc::internal::CancelInterceptorBatchMethods::ModifySendMessage
void ModifySendMessage(const void *) override
Overwrites the message to be sent with message.
Definition: interceptor_common.h:450
grpc::internal::InterceptorBatchMethodsImpl::GetSendStatus
Status GetSendStatus() override
Returns the status to be sent. Valid for PRE_SEND_STATUS interceptions.
Definition: interceptor_common.h:108
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:97
grpc_status_code
grpc_status_code
Definition: status.h:28
grpc::internal::InterceptorBatchMethodsImpl::SetRecvInitialMetadata
void SetRecvInitialMetadata(MetadataMap *map)
Definition: interceptor_common.h:174
grpc::internal::CancelInterceptorBatchMethods::GetSendStatus
Status GetSendStatus() override
Returns the status to be sent. Valid for PRE_SEND_STATUS interceptions.
Definition: interceptor_common.h:461
grpc::internal::InterceptorBatchMethodsImpl::SetCallOpSetInterface
void SetCallOpSetInterface(CallOpSetInterface *ops)
Definition: interceptor_common.h:220
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:125
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::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:510
grpc::internal::InterceptorBatchMethodsImpl::ClearState
void ClearState()
Definition: interceptor_common.h:202
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:132
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:102
grpc::internal::CancelInterceptorBatchMethods::GetInterceptedChannel
std::unique_ptr< ChannelInterface > GetInterceptedChannel() override
Gets an intercepted channel.
Definition: interceptor_common.h:504
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:157
grpc::internal::CancelInterceptorBatchMethods::GetRecvMessage
void * GetRecvMessage() override
Returns a pointer to the modifiable received message.
Definition: interceptor_common.h:478
log.h
grpc::internal::InterceptorBatchMethodsImpl::RunInterceptors
bool RunInterceptors(std::function< void(void)> f)
Definition: interceptor_common.h:263
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:119
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:443
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:209
grpc::internal::InterceptorBatchMethodsImpl::SetRecvStatus
void SetRecvStatus(Status *status)
Definition: interceptor_common.h:178
grpc::internal::InterceptorBatchMethodsImpl::GetRecvMessage
void * GetRecvMessage() override
Returns a pointer to the modifiable received message.
Definition: interceptor_common.h:123
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:484
grpc::internal::CancelInterceptorBatchMethods::ModifySendStatus
void ModifySendStatus(const Status &) override
Overwrites the status with status.
Definition: interceptor_common.h:467
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:430
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:104
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:92
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:169
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:491
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:424
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:195
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:138
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:143
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:130
call.h
grpc::internal::InterceptorBatchMethodsImpl::GetInterceptedChannel
std::unique_ptr< ChannelInterface > GetInterceptedChannel() override
Gets an intercepted channel.
Definition: interceptor_common.h:184
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:419
grpc::internal::CancelInterceptorBatchMethods::GetSendMessageStatus
bool GetSendMessageStatus() override
Checks whether the SEND MESSAGE op succeeded.
Definition: interceptor_common.h:436
intercepted_channel.h
grpc::internal::InterceptorBatchMethodsImpl::RunInterceptors
bool RunInterceptors()
Definition: interceptor_common.h:239
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:515
grpc::internal::CancelInterceptorBatchMethods
Definition: interceptor_common.h:411
grpc::internal::InterceptorBatchMethodsImpl::SetRecvTrailingMetadata
void SetRecvTrailingMetadata(MetadataMap *map)
Definition: interceptor_common.h:180
grpc::internal::InterceptorBatchMethodsImpl::SetSendInitialMetadata
void SetSendInitialMetadata(std::multimap< std::string, std::string > *metadata)
Definition: interceptor_common.h:152
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:414
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:164
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:455
grpc::internal::InterceptorBatchMethodsImpl::AddInterceptionHookPoint
void AddInterceptionHookPoint(experimental::InterceptionHookPoints type)
Definition: interceptor_common.h:79
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:497