GRPC C++  1.30.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_CODEGEN_INTERCEPTOR_COMMON_H
20 #define GRPCPP_IMPL_CODEGEN_INTERCEPTOR_COMMON_H
21 
22 #include <array>
23 #include <functional>
24 
30 
32 
33 namespace grpc {
34 namespace internal {
35 
38  public:
40  for (auto i = static_cast<experimental::InterceptionHookPoints>(0);
42  i = static_cast<experimental::InterceptionHookPoints>(
43  static_cast<size_t>(i) + 1)) {
44  hooks_[static_cast<size_t>(i)] = false;
45  }
46  }
47 
49 
52  return hooks_[static_cast<size_t>(type)];
53  }
54 
55  void Proceed() override {
56  if (call_->client_rpc_info() != nullptr) {
57  return ProceedClient();
58  }
59  GPR_CODEGEN_ASSERT(call_->server_rpc_info() != nullptr);
60  ProceedServer();
61  }
62 
63  void Hijack() override {
64  // Only the client can hijack when sending down initial metadata
65  GPR_CODEGEN_ASSERT(!reverse_ && ops_ != nullptr &&
66  call_->client_rpc_info() != nullptr);
67  // It is illegal to call Hijack twice
68  GPR_CODEGEN_ASSERT(!ran_hijacking_interceptor_);
69  auto* rpc_info = call_->client_rpc_info();
70  rpc_info->hijacked_ = true;
71  rpc_info->hijacked_interceptor_ = current_interceptor_index_;
72  ClearHookPoints();
73  ops_->SetHijackingState();
74  ran_hijacking_interceptor_ = true;
75  rpc_info->RunInterceptor(this, current_interceptor_index_);
76  }
77 
79  hooks_[static_cast<size_t>(type)] = true;
80  }
81 
83  GPR_CODEGEN_ASSERT(orig_send_message_ != nullptr);
84  if (*orig_send_message_ != nullptr) {
85  GPR_CODEGEN_ASSERT(serializer_(*orig_send_message_).ok());
86  *orig_send_message_ = nullptr;
87  }
88  return send_message_;
89  }
90 
91  const void* GetSendMessage() override {
92  GPR_CODEGEN_ASSERT(orig_send_message_ != nullptr);
93  return *orig_send_message_;
94  }
95 
96  void ModifySendMessage(const void* message) override {
97  GPR_CODEGEN_ASSERT(orig_send_message_ != nullptr);
98  *orig_send_message_ = message;
99  }
100 
101  bool GetSendMessageStatus() override { return !*fail_send_message_; }
102 
103  std::multimap<grpc::string, grpc::string>* GetSendInitialMetadata() override {
104  return send_initial_metadata_;
105  }
106 
107  Status GetSendStatus() override {
108  return Status(static_cast<StatusCode>(*code_), *error_message_,
109  *error_details_);
110  }
111 
112  void ModifySendStatus(const Status& status) override {
113  *code_ = static_cast<grpc_status_code>(status.error_code());
114  *error_details_ = status.error_details();
115  *error_message_ = status.error_message();
116  }
117 
118  std::multimap<grpc::string, grpc::string>* GetSendTrailingMetadata()
119  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  GPR_CODEGEN_ASSERT(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<grpc::string, grpc::string>* metadata) {
154  send_initial_metadata_ = metadata;
155  }
156 
157  void SetSendStatus(grpc_status_code* code, grpc::string* error_details,
158  grpc::string* error_message) {
159  code_ = code;
160  error_details_ = error_details;
161  error_message_ = error_message;
162  }
163 
165  std::multimap<grpc::string, grpc::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  GPR_CODEGEN_ASSERT(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  if (client_rpc_info->interceptors_.size() == 0) {
228  return true;
229  } else {
230  return false;
231  }
232  }
233 
234  auto* server_rpc_info = call_->server_rpc_info();
235  if (server_rpc_info == nullptr ||
236  server_rpc_info->interceptors_.size() == 0) {
237  return true;
238  }
239  return false;
240  }
241 
242  // This should be used only by subclasses of CallOpSetInterface. SetCall and
243  // SetCallOpSetInterface should have been called before this. After all the
244  // interceptors are done running, either ContinueFillOpsAfterInterception or
245  // ContinueFinalizeOpsAfterInterception will be called. Note that neither of
246  // them is invoked if there were no interceptors registered.
248  GPR_CODEGEN_ASSERT(ops_);
249  auto* client_rpc_info = call_->client_rpc_info();
250  if (client_rpc_info != nullptr) {
251  if (client_rpc_info->interceptors_.size() == 0) {
252  return true;
253  } else {
254  RunClientInterceptors();
255  return false;
256  }
257  }
258 
259  auto* server_rpc_info = call_->server_rpc_info();
260  if (server_rpc_info == nullptr ||
261  server_rpc_info->interceptors_.size() == 0) {
262  return true;
263  }
264  RunServerInterceptors();
265  return false;
266  }
267 
268  // Returns true if no interceptors are run. Returns false otherwise if there
269  // are interceptors registered. After the interceptors are done running \a f
270  // will be invoked. This is to be used only by BaseAsyncRequest and
271  // SyncRequest.
272  bool RunInterceptors(std::function<void(void)> f) {
273  // This is used only by the server for initial call request
274  GPR_CODEGEN_ASSERT(reverse_ == true);
275  GPR_CODEGEN_ASSERT(call_->client_rpc_info() == nullptr);
276  auto* server_rpc_info = call_->server_rpc_info();
277  if (server_rpc_info == nullptr ||
278  server_rpc_info->interceptors_.size() == 0) {
279  return true;
280  }
281  callback_ = std::move(f);
282  RunServerInterceptors();
283  return false;
284  }
285 
286  private:
287  void RunClientInterceptors() {
288  auto* rpc_info = call_->client_rpc_info();
289  if (!reverse_) {
290  current_interceptor_index_ = 0;
291  } else {
292  if (rpc_info->hijacked_) {
293  current_interceptor_index_ = rpc_info->hijacked_interceptor_;
294  } else {
295  current_interceptor_index_ = rpc_info->interceptors_.size() - 1;
296  }
297  }
298  rpc_info->RunInterceptor(this, current_interceptor_index_);
299  }
300 
301  void RunServerInterceptors() {
302  auto* rpc_info = call_->server_rpc_info();
303  if (!reverse_) {
304  current_interceptor_index_ = 0;
305  } else {
306  current_interceptor_index_ = rpc_info->interceptors_.size() - 1;
307  }
308  rpc_info->RunInterceptor(this, current_interceptor_index_);
309  }
310 
311  void ProceedClient() {
312  auto* rpc_info = call_->client_rpc_info();
313  if (rpc_info->hijacked_ && !reverse_ &&
314  current_interceptor_index_ == rpc_info->hijacked_interceptor_ &&
315  !ran_hijacking_interceptor_) {
316  // We now need to provide hijacked recv ops to this interceptor
317  ClearHookPoints();
318  ops_->SetHijackingState();
319  ran_hijacking_interceptor_ = true;
320  rpc_info->RunInterceptor(this, current_interceptor_index_);
321  return;
322  }
323  if (!reverse_) {
324  current_interceptor_index_++;
325  // We are going down the stack of interceptors
326  if (current_interceptor_index_ < rpc_info->interceptors_.size()) {
327  if (rpc_info->hijacked_ &&
328  current_interceptor_index_ > rpc_info->hijacked_interceptor_) {
329  // This is a hijacked RPC and we are done with hijacking
331  } else {
332  rpc_info->RunInterceptor(this, current_interceptor_index_);
333  }
334  } else {
335  // we are done running all the interceptors without any hijacking
337  }
338  } else {
339  // We are going up the stack of interceptors
340  if (current_interceptor_index_ > 0) {
341  // Continue running interceptors
342  current_interceptor_index_--;
343  rpc_info->RunInterceptor(this, current_interceptor_index_);
344  } else {
345  // we are done running all the interceptors without any hijacking
347  }
348  }
349  }
350 
351  void ProceedServer() {
352  auto* rpc_info = call_->server_rpc_info();
353  if (!reverse_) {
354  current_interceptor_index_++;
355  if (current_interceptor_index_ < rpc_info->interceptors_.size()) {
356  return rpc_info->RunInterceptor(this, current_interceptor_index_);
357  } else if (ops_) {
358  return ops_->ContinueFillOpsAfterInterception();
359  }
360  } else {
361  // We are going up the stack of interceptors
362  if (current_interceptor_index_ > 0) {
363  // Continue running interceptors
364  current_interceptor_index_--;
365  return rpc_info->RunInterceptor(this, current_interceptor_index_);
366  } else if (ops_) {
368  }
369  }
370  GPR_CODEGEN_ASSERT(callback_);
371  callback_();
372  }
373 
374  void ClearHookPoints() {
375  for (auto i = static_cast<experimental::InterceptionHookPoints>(0);
377  i = static_cast<experimental::InterceptionHookPoints>(
378  static_cast<size_t>(i) + 1)) {
379  hooks_[static_cast<size_t>(i)] = false;
380  }
381  }
382 
383  std::array<bool,
384  static_cast<size_t>(
386  hooks_;
387 
388  size_t current_interceptor_index_ = 0; // Current iterator
389  bool reverse_ = false;
390  bool ran_hijacking_interceptor_ = false;
391  Call* call_ = nullptr; // The Call object is present along with CallOpSet
392  // object/callback
393  CallOpSetInterface* ops_ = nullptr;
394  std::function<void(void)> callback_;
395 
396  ByteBuffer* send_message_ = nullptr;
397  bool* fail_send_message_ = nullptr;
398  const void** orig_send_message_ = nullptr;
399  std::function<Status(const void*)> serializer_;
400 
401  std::multimap<grpc::string, grpc::string>* send_initial_metadata_;
402 
403  grpc_status_code* code_ = nullptr;
404  grpc::string* error_details_ = nullptr;
405  grpc::string* error_message_ = nullptr;
406 
407  std::multimap<grpc::string, grpc::string>* send_trailing_metadata_ = nullptr;
408 
409  void* recv_message_ = nullptr;
410  bool* hijacked_recv_message_failed_ = nullptr;
411 
412  MetadataMap* recv_initial_metadata_ = nullptr;
413 
414  Status* recv_status_ = nullptr;
415 
416  MetadataMap* recv_trailing_metadata_ = nullptr;
417 };
418 
419 // A special implementation of InterceptorBatchMethods to send a Cancel
420 // notification down the interceptor stack
423  public:
425  experimental::InterceptionHookPoints type) override {
427  return true;
428  } else {
429  return false;
430  }
431  }
432 
433  void Proceed() override {
434  // This is a no-op. For actual continuation of the RPC simply needs to
435  // return from the Intercept method
436  }
437 
438  void Hijack() override {
439  // Only the client can hijack when sending down initial metadata
440  GPR_CODEGEN_ASSERT(false &&
441  "It is illegal to call Hijack on a method which has a "
442  "Cancel notification");
443  }
444 
446  GPR_CODEGEN_ASSERT(false &&
447  "It is illegal to call GetSendMessage on a method which "
448  "has a Cancel notification");
449  return nullptr;
450  }
451 
452  bool GetSendMessageStatus() override {
454  false &&
455  "It is illegal to call GetSendMessageStatus on a method which "
456  "has a Cancel notification");
457  return false;
458  }
459 
460  const void* GetSendMessage() override {
462  false &&
463  "It is illegal to call GetOriginalSendMessage on a method which "
464  "has a Cancel notification");
465  return nullptr;
466  }
467 
468  void ModifySendMessage(const void* /*message*/) override {
470  false &&
471  "It is illegal to call ModifySendMessage on a method which "
472  "has a Cancel notification");
473  }
474 
475  std::multimap<grpc::string, grpc::string>* GetSendInitialMetadata() override {
476  GPR_CODEGEN_ASSERT(false &&
477  "It is illegal to call GetSendInitialMetadata on a "
478  "method which has a Cancel notification");
479  return nullptr;
480  }
481 
482  Status GetSendStatus() override {
483  GPR_CODEGEN_ASSERT(false &&
484  "It is illegal to call GetSendStatus on a method which "
485  "has a Cancel notification");
486  return Status();
487  }
488 
489  void ModifySendStatus(const Status& /*status*/) override {
490  GPR_CODEGEN_ASSERT(false &&
491  "It is illegal to call ModifySendStatus on a method "
492  "which has a Cancel notification");
493  return;
494  }
495 
496  std::multimap<grpc::string, grpc::string>* GetSendTrailingMetadata()
497  override {
498  GPR_CODEGEN_ASSERT(false &&
499  "It is illegal to call GetSendTrailingMetadata on a "
500  "method which has a Cancel notification");
501  return nullptr;
502  }
503 
504  void* GetRecvMessage() override {
505  GPR_CODEGEN_ASSERT(false &&
506  "It is illegal to call GetRecvMessage on a method which "
507  "has a Cancel notification");
508  return nullptr;
509  }
510 
511  std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvInitialMetadata()
512  override {
513  GPR_CODEGEN_ASSERT(false &&
514  "It is illegal to call GetRecvInitialMetadata on a "
515  "method which has a Cancel notification");
516  return nullptr;
517  }
518 
519  Status* GetRecvStatus() override {
520  GPR_CODEGEN_ASSERT(false &&
521  "It is illegal to call GetRecvStatus on a method which "
522  "has a Cancel notification");
523  return nullptr;
524  }
525 
526  std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata()
527  override {
528  GPR_CODEGEN_ASSERT(false &&
529  "It is illegal to call GetRecvTrailingMetadata on a "
530  "method which has a Cancel notification");
531  return nullptr;
532  }
533 
534  std::unique_ptr<ChannelInterface> GetInterceptedChannel() override {
535  GPR_CODEGEN_ASSERT(false &&
536  "It is illegal to call GetInterceptedChannel on a "
537  "method which has a Cancel notification");
538  return std::unique_ptr<ChannelInterface>(nullptr);
539  }
540 
541  void FailHijackedRecvMessage() override {
542  GPR_CODEGEN_ASSERT(false &&
543  "It is illegal to call FailHijackedRecvMessage on a "
544  "method which has a Cancel notification");
545  }
546 
547  void FailHijackedSendMessage() override {
548  GPR_CODEGEN_ASSERT(false &&
549  "It is illegal to call FailHijackedSendMessage on a "
550  "method which has a Cancel notification");
551  }
552 };
553 } // namespace internal
554 } // namespace grpc
555 
556 #endif // GRPCPP_IMPL_CODEGEN_INTERCEPTOR_COMMON_H
grpc::Status::error_details
grpc::string error_details() const
Return the (binary) error details.
Definition: status.h:115
grpc::internal::InterceptorBatchMethodsImpl::GetSerializedSendMessage
ByteBuffer * GetSerializedSendMessage() override
Send Message Methods GetSerializedSendMessage and GetSendMessage/ModifySendMessage are the available ...
Definition: interceptor_common.h:82
grpc::internal::InterceptorBatchMethodsImpl::Proceed
void Proceed() override
Signal that the interceptor is done intercepting the current batch of the RPC.
Definition: interceptor_common.h:55
grpc::internal::InterceptorBatchMethodsImpl::ModifySendStatus
void ModifySendStatus(const Status &status) override
Overwrites the status with status.
Definition: interceptor_common.h:112
grpc::internal::CancelInterceptorBatchMethods::ModifySendMessage
void ModifySendMessage(const void *) override
Overwrites the message to be sent with message.
Definition: interceptor_common.h:468
grpc::internal::InterceptorBatchMethodsImpl::GetSendStatus
Status GetSendStatus() override
Returns the status to be sent. Valid for PRE_SEND_STATUS interceptions.
Definition: interceptor_common.h:107
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:50
grpc_status_code
grpc_status_code
Definition: status.h:26
grpc
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
grpc::internal::InterceptorBatchMethodsImpl::ModifySendMessage
void ModifySendMessage(const void *message) override
Overwrites the message to be sent with message.
Definition: interceptor_common.h:96
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:482
grpc::internal::CancelInterceptorBatchMethods::GetSendTrailingMetadata
std::multimap< grpc::string, grpc::string > * GetSendTrailingMetadata() override
Returns a modifiable multimap of the trailing metadata to be sent.
Definition: interceptor_common.h:496
grpc::internal::InterceptorBatchMethodsImpl::SetCallOpSetInterface
void SetCallOpSetInterface(CallOpSetInterface *ops)
Definition: interceptor_common.h:220
grpc::experimental::InterceptionHookPoints::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:39
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:541
grpc::internal::InterceptorBatchMethodsImpl::ClearState
void ClearState()
Definition: interceptor_common.h:202
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:38
server_interceptor.h
grpc::internal::InterceptorBatchMethodsImpl::GetSendTrailingMetadata
std::multimap< grpc::string, grpc::string > * GetSendTrailingMetadata() override
Returns a modifiable multimap of the trailing metadata to be sent.
Definition: interceptor_common.h:118
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::InterceptorBatchMethodsImpl::GetSendInitialMetadata
std::multimap< grpc::string, grpc::string > * GetSendInitialMetadata() override
Returns a modifiable multimap of the initial metadata to be sent.
Definition: interceptor_common.h:103
grpc::internal::MetadataMap
Definition: metadata_map.h:33
grpc::experimental::InterceptionHookPoints::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:66
grpc::internal::InterceptorBatchMethodsImpl::GetSendMessageStatus
bool GetSendMessageStatus() override
Checks whether the SEND MESSAGE op succeeded.
Definition: interceptor_common.h:101
grpc::internal::CancelInterceptorBatchMethods::GetInterceptedChannel
std::unique_ptr< ChannelInterface > GetInterceptedChannel() override
Gets an intercepted channel.
Definition: interceptor_common.h:534
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:31
grpc::internal::InterceptorBatchMethodsImpl::~InterceptorBatchMethodsImpl
~InterceptorBatchMethodsImpl()
Definition: interceptor_common.h:48
grpc::internal::CancelInterceptorBatchMethods::GetRecvMessage
void * GetRecvMessage() override
Returns a pointer to the modifiable received message.
Definition: interceptor_common.h:504
grpc::internal::InterceptorBatchMethodsImpl::RunInterceptors
bool RunInterceptors(std::function< void(void)> f)
Definition: interceptor_common.h:272
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:460
grpc::internal::CallOpSetInterface
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call_op_set_interface.h:34
grpc::ByteBuffer
A sequence of bytes.
Definition: byte_buffer.h:67
grpc::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::SetSendStatus
void SetSendStatus(grpc_status_code *code, grpc::string *error_details, grpc::string *error_message)
Definition: interceptor_common.h:157
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:511
grpc::internal::CancelInterceptorBatchMethods::GetSendInitialMetadata
std::multimap< grpc::string, grpc::string > * GetSendInitialMetadata() override
Returns a modifiable multimap of the initial metadata to be sent.
Definition: interceptor_common.h:475
grpc::internal::InterceptorBatchMethodsImpl::SetSendTrailingMetadata
void SetSendTrailingMetadata(std::multimap< grpc::string, grpc::string > *metadata)
Definition: interceptor_common.h:164
grpc::internal::CancelInterceptorBatchMethods::ModifySendStatus
void ModifySendStatus(const Status &) override
Overwrites the status with status.
Definition: interceptor_common.h:489
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:63
grpc::internal::InterceptedChannel
An InterceptedChannel is available to client Interceptors.
Definition: intercepted_channel.h:38
grpc::internal::CancelInterceptorBatchMethods::GetSerializedSendMessage
ByteBuffer * GetSerializedSendMessage() override
Send Message Methods GetSerializedSendMessage and GetSendMessage/ModifySendMessage are the available ...
Definition: interceptor_common.h:445
call_op_set_interface.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:91
client_interceptor.h
grpc::protobuf::util::Status
::google::protobuf::util::Status Status
Definition: config_protobuf.h:90
grpc::experimental::InterceptionHookPoints::NUM_INTERCEPTION_HOOKS
grpc::experimental::InterceptionHookPoints::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:110
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:519
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:438
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:81
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::CallOpSetInterface::ContinueFinalizeResultAfterInterception
virtual void ContinueFinalizeResultAfterInterception()=0
call.h
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
grpc::Status::error_message
grpc::string error_message() const
Return the instance's error message.
Definition: status.h:112
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:93
grpc::string
std::string string
Definition: config.h:35
grpc::internal::CancelInterceptorBatchMethods::Proceed
void Proceed() override
Signal that the interceptor is done intercepting the current batch of the RPC.
Definition: interceptor_common.h:433
grpc::internal::CancelInterceptorBatchMethods::GetSendMessageStatus
bool GetSendMessageStatus() override
Checks whether the SEND MESSAGE op succeeded.
Definition: interceptor_common.h:452
GPR_CODEGEN_ASSERT
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
intercepted_channel.h
grpc::internal::InterceptorBatchMethodsImpl::RunInterceptors
bool RunInterceptors()
Definition: interceptor_common.h:247
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:547
grpc::internal::InterceptorBatchMethodsImpl::SetSendInitialMetadata
void SetSendInitialMetadata(std::multimap< grpc::string, grpc::string > *metadata)
Definition: interceptor_common.h:152
grpc::internal::CancelInterceptorBatchMethods
Definition: interceptor_common.h:421
grpc::internal::InterceptorBatchMethodsImpl::SetRecvTrailingMetadata
void SetRecvTrailingMetadata(MetadataMap *map)
Definition: interceptor_common.h:180
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:424
grpc::experimental::InterceptionHookPoints
InterceptionHookPoints
An enumeration of different possible points at which the Intercept method of the Interceptor interfac...
Definition: interceptor.h:54
grpc::internal::InterceptorBatchMethodsImpl
Definition: interceptor_common.h:36
grpc::internal::InterceptorBatchMethodsImpl::AddInterceptionHookPoint
void AddInterceptionHookPoint(experimental::InterceptionHookPoints type)
Definition: interceptor_common.h:78
grpc::internal::Call::client_rpc_info
experimental::ClientRpcInfo * client_rpc_info() const
Definition: call.h:77
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:526