GRPC C++  1.26.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 
27 
28 namespace grpc {
29 
30 class ChannelInterface;
31 class Status;
32 
33 namespace experimental {
34 
57  PRE_SEND_STATUS, // server only
58  PRE_SEND_CLOSE, // client only: WritesDone for stream; after write in unary
67  POST_RECV_STATUS, // client only
68  POST_RECV_CLOSE, // server only
77 };
78 
92  public:
106  virtual void Proceed() = 0;
112  virtual void Hijack() = 0;
113 
131 
136 
140  virtual const void* GetSendMessage() = 0;
141 
149  virtual void ModifySendMessage(const void* message) = 0;
150 
153  virtual bool GetSendMessageStatus() = 0;
154 
158  virtual std::multimap<grpc::string, grpc::string>*
160 
162  virtual Status GetSendStatus() = 0;
163 
166  virtual void ModifySendStatus(const Status& status) = 0;
167 
171  virtual std::multimap<grpc::string, grpc::string>*
173 
179  virtual void* GetRecvMessage() = 0;
180 
184  virtual std::multimap<grpc::string_ref, grpc::string_ref>*
186 
189  virtual Status* GetRecvStatus() = 0;
190 
193  virtual std::multimap<grpc::string_ref, grpc::string_ref>*
195 
201  virtual std::unique_ptr<ChannelInterface> GetInterceptedChannel() = 0;
202 
206  virtual void FailHijackedRecvMessage() = 0;
207 
210  virtual void FailHijackedSendMessage() = 0;
211 };
212 
215 class Interceptor {
216  public:
217  virtual ~Interceptor() {}
218 
221  virtual void Intercept(InterceptorBatchMethods* methods) = 0;
222 };
223 
224 } // namespace experimental
225 } // namespace grpc
226 
227 #endif // GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H
A sequence of bytes.
Definition: byte_buffer.h:67
Did it work? If it didn't, why?
Definition: status.h:31
Class that is passed as an argument to the Intercept method of the application's Interceptor interfac...
Definition: interceptor.h:91
virtual std::multimap< grpc::string, grpc::string > * GetSendInitialMetadata()=0
Returns a modifiable multimap of the initial metadata to be sent.
virtual ByteBuffer * GetSerializedSendMessage()=0
Send Message Methods GetSerializedSendMessage and GetSendMessage/ModifySendMessage are the available ...
virtual Status GetSendStatus()=0
Returns the status to be sent. Valid for PRE_SEND_STATUS interceptions.
virtual void * GetRecvMessage()=0
Returns a pointer to the modifiable received message.
virtual const void * GetSendMessage()=0
Returns a non-modifiable pointer to the non-serialized form of the message to be sent.
virtual void FailHijackedRecvMessage()=0
On a hijacked RPC, an interceptor can decide to fail a PRE_RECV_MESSAGE op.
virtual void ModifySendStatus(const Status &status)=0
Overwrites the status with status.
virtual ~InterceptorBatchMethods()
Definition: interceptor.h:93
virtual void Proceed()=0
Signal that the interceptor is done intercepting the current batch of the RPC.
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...
virtual bool QueryInterceptionHookPoint(InterceptionHookPoints type)=0
Determine whether the current batch has an interception hook point of type type.
virtual void ModifySendMessage(const void *message)=0
Overwrites the message to be sent with message.
virtual void FailHijackedSendMessage()=0
On a hijacked RPC/ to-be hijacked RPC, this can be called to fail a SEND MESSAGE op.
virtual std::multimap< grpc::string_ref, grpc::string_ref > * GetRecvInitialMetadata()=0
Returns a modifiable multimap of the received initial metadata.
virtual bool GetSendMessageStatus()=0
Checks whether the SEND MESSAGE op succeeded.
virtual std::unique_ptr< ChannelInterface > GetInterceptedChannel()=0
Gets an intercepted channel.
virtual std::multimap< grpc::string, grpc::string > * GetSendTrailingMetadata()=0
Returns a modifiable multimap of the trailing metadata to be sent.
virtual Status * GetRecvStatus()=0
Returns a modifiable view of the received status on PRE_RECV_STATUS and POST_RECV_STATUS interception...
virtual void Hijack()=0
Indicate that the interceptor has hijacked the RPC (only valid if the batch contains send_initial_met...
Interface for an interceptor.
Definition: interceptor.h:215
virtual void Intercept(InterceptorBatchMethods *methods)=0
The one public method of an Interceptor interface.
virtual ~Interceptor()
Definition: interceptor.h:217
InterceptionHookPoints
An enumeration of different possible points at which the Intercept method of the Interceptor interfac...
Definition: interceptor.h:52
@ POST_RECV_INITIAL_METADATA
The following two are for all clients and servers.
@ PRE_SEND_INITIAL_METADATA
The first three in this list are for clients and servers.
@ PRE_RECV_INITIAL_METADATA
The following three are for hijacked clients only.
@ PRE_SEND_CANCEL
This is a special hook point available to both clients and servers when TryCancel() is performed.
::google::protobuf::util::Status Status
Definition: config_protobuf.h:90
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24