GRPC C++  1.30.0
interceptor.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_H
20 #define GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H
21 
22 #include <memory>
23 
29 
30 namespace grpc {
31 
32 class ChannelInterface;
33 class Status;
34 
35 namespace experimental {
36 
59  PRE_SEND_STATUS, // server only
60  PRE_SEND_CLOSE, // client only: WritesDone for stream; after write in unary
69  POST_RECV_STATUS, // client only
70  POST_RECV_CLOSE, // server only
79 };
80 
94  public:
108  virtual void Proceed() = 0;
114  virtual void Hijack() = 0;
115 
133 
137  virtual ByteBuffer* GetSerializedSendMessage() = 0;
138 
142  virtual const void* GetSendMessage() = 0;
143 
151  virtual void ModifySendMessage(const void* message) = 0;
152 
155  virtual bool GetSendMessageStatus() = 0;
156 
160  virtual std::multimap<grpc::string, grpc::string>*
162 
164  virtual Status GetSendStatus() = 0;
165 
168  virtual void ModifySendStatus(const Status& status) = 0;
169 
173  virtual std::multimap<grpc::string, grpc::string>*
175 
181  virtual void* GetRecvMessage() = 0;
182 
186  virtual std::multimap<grpc::string_ref, grpc::string_ref>*
188 
191  virtual Status* GetRecvStatus() = 0;
192 
195  virtual std::multimap<grpc::string_ref, grpc::string_ref>*
197 
203  virtual std::unique_ptr<ChannelInterface> GetInterceptedChannel() = 0;
204 
208  virtual void FailHijackedRecvMessage() = 0;
209 
212  virtual void FailHijackedSendMessage() = 0;
213 };
214 
217 class Interceptor {
218  public:
219  virtual ~Interceptor() {}
220 
223  virtual void Intercept(InterceptorBatchMethods* methods) = 0;
224 };
225 
226 } // namespace experimental
227 } // namespace grpc
228 
229 #endif // GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H
grpc::experimental::InterceptorBatchMethods::GetRecvStatus
virtual Status * GetRecvStatus()=0
Returns a modifiable view of the received status on PRE_RECV_STATUS and POST_RECV_STATUS interception...
grpc::experimental::Interceptor::Intercept
virtual void Intercept(InterceptorBatchMethods *methods)=0
The one public method of an Interceptor interface.
grpc::experimental::InterceptionHookPoints::POST_RECV_STATUS
grpc::experimental::InterceptionHookPoints::PRE_SEND_CLOSE
grpc::experimental::InterceptorBatchMethods::QueryInterceptionHookPoint
virtual bool QueryInterceptionHookPoint(InterceptionHookPoints type)=0
Determine whether the current batch has an interception hook point of type type.
grpc::experimental::InterceptorBatchMethods::FailHijackedRecvMessage
virtual void FailHijackedRecvMessage()=0
On a hijacked RPC, an interceptor can decide to fail a PRE_RECV_MESSAGE op.
grpc::experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA
The first three in this list are for clients and servers.
grpc
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
grpc::experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA
The following two are for all clients and servers.
grpc::experimental::InterceptorBatchMethods::FailHijackedSendMessage
virtual void FailHijackedSendMessage()=0
On a hijacked RPC/ to-be hijacked RPC, this can be called to fail a SEND MESSAGE op.
grpc::experimental::InterceptionHookPoints::POST_RECV_MESSAGE
config.h
grpc::experimental::InterceptionHookPoints::PRE_RECV_MESSAGE
grpc::experimental::InterceptionHookPoints::PRE_RECV_STATUS
grpc::experimental::InterceptorBatchMethods::GetSendMessage
virtual const void * GetSendMessage()=0
Returns a non-modifiable pointer to the non-serialized form of the message to be sent.
grpc::experimental::InterceptorBatchMethods::GetSendTrailingMetadata
virtual std::multimap< grpc::string, grpc::string > * GetSendTrailingMetadata()=0
Returns a modifiable multimap of the trailing metadata to be sent.
core_codegen_interface.h
grpc::experimental::InterceptorBatchMethods::Hijack
virtual void Hijack()=0
Indicate that the interceptor has hijacked the RPC (only valid if the batch contains send_initial_met...
grpc::experimental::InterceptorBatchMethods::GetRecvMessage
virtual void * GetRecvMessage()=0
Returns a pointer to the modifiable received message.
byte_buffer.h
grpc::experimental::InterceptorBatchMethods::GetSendInitialMetadata
virtual std::multimap< grpc::string, grpc::string > * GetSendInitialMetadata()=0
Returns a modifiable multimap of the initial metadata to be sent.
grpc::experimental::InterceptorBatchMethods::GetSendMessageStatus
virtual bool GetSendMessageStatus()=0
Checks whether the SEND MESSAGE op succeeded.
metadata_map.h
grpc::experimental::InterceptionHookPoints::PRE_SEND_STATUS
grpc::experimental::InterceptionHookPoints::PRE_SEND_CANCEL
This is a special hook point available to both clients and servers when TryCancel() is performed.
grpc::experimental::InterceptorBatchMethods::ModifySendMessage
virtual void ModifySendMessage(const void *message)=0
Overwrites the message to be sent with message.
grpc_types.h
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:31
grpc::experimental::InterceptorBatchMethods::GetInterceptedChannel
virtual std::unique_ptr< ChannelInterface > GetInterceptedChannel()=0
Gets an intercepted channel.
grpc::experimental::InterceptorBatchMethods::GetRecvTrailingMetadata
virtual std::multimap< grpc::string_ref, grpc::string_ref > * GetRecvTrailingMetadata()=0
Returns a modifiable multimap of the received trailing metadata on PRE_RECV_STATUS and POST_RECV_STAT...
grpc::experimental::InterceptorBatchMethods::GetRecvInitialMetadata
virtual std::multimap< grpc::string_ref, grpc::string_ref > * GetRecvInitialMetadata()=0
Returns a modifiable multimap of the received initial metadata.
grpc::ByteBuffer
A sequence of bytes.
Definition: byte_buffer.h:67
grpc::experimental::Interceptor::~Interceptor
virtual ~Interceptor()
Definition: interceptor.h:219
grpc::experimental::InterceptorBatchMethods::GetSerializedSendMessage
virtual ByteBuffer * GetSerializedSendMessage()=0
Send Message Methods GetSerializedSendMessage and GetSendMessage/ModifySendMessage are the available ...
grpc::experimental::InterceptorBatchMethods::~InterceptorBatchMethods
virtual ~InterceptorBatchMethods()
Definition: interceptor.h:95
grpc::protobuf::util::Status
::google::protobuf::util::Status Status
Definition: config_protobuf.h:90
grpc::experimental::Interceptor
Interface for an interceptor.
Definition: interceptor.h:217
grpc::experimental::InterceptionHookPoints::NUM_INTERCEPTION_HOOKS
grpc::experimental::InterceptionHookPoints::PRE_SEND_MESSAGE
grpc::experimental::InterceptorBatchMethods::GetSendStatus
virtual Status GetSendStatus()=0
Returns the status to be sent. Valid for PRE_SEND_STATUS interceptions.
grpc::experimental::InterceptorBatchMethods::ModifySendStatus
virtual void ModifySendStatus(const Status &status)=0
Overwrites the status with status.
grpc::experimental::InterceptionHookPoints::POST_SEND_MESSAGE
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::experimental::InterceptionHookPoints::POST_RECV_CLOSE
grpc::experimental::InterceptorBatchMethods::Proceed
virtual void Proceed()=0
Signal that the interceptor is done intercepting the current batch of the RPC.
grpc::experimental::InterceptionHookPoints
InterceptionHookPoints
An enumeration of different possible points at which the Intercept method of the Interceptor interfac...
Definition: interceptor.h:54
grpc::experimental::InterceptionHookPoints::PRE_RECV_INITIAL_METADATA
The following three are for hijacked clients only.