GRPC C++  1.19.0-dev
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 
53  PRE_SEND_STATUS, // server only
54  PRE_SEND_CLOSE, // client only: WritesDone for stream; after write in unary
63  POST_RECV_STATUS, // client only
64  POST_RECV_CLOSE, // server only
73 };
74 
88  public:
92  virtual bool QueryInterceptionHookPoint(InterceptionHookPoints type) = 0;
102  virtual void Proceed() = 0;
108  virtual void Hijack() = 0;
109 
113  virtual ByteBuffer* GetSerializedSendMessage() = 0;
114 
119  virtual const void* GetSendMessage() = 0;
120 
126  virtual void ModifySendMessage(const void* message) = 0;
127 
130  virtual bool GetSendMessageStatus() = 0;
131 
135  virtual std::multimap<grpc::string, grpc::string>*
136  GetSendInitialMetadata() = 0;
137 
139  virtual Status GetSendStatus() = 0;
140 
143  virtual void ModifySendStatus(const Status& status) = 0;
144 
148  virtual std::multimap<grpc::string, grpc::string>*
149  GetSendTrailingMetadata() = 0;
150 
155  virtual void* GetRecvMessage() = 0;
156 
159  virtual std::multimap<grpc::string_ref, grpc::string_ref>*
160  GetRecvInitialMetadata() = 0;
161 
164  virtual Status* GetRecvStatus() = 0;
165 
168  virtual std::multimap<grpc::string_ref, grpc::string_ref>*
169  GetRecvTrailingMetadata() = 0;
170 
176  virtual std::unique_ptr<ChannelInterface> GetInterceptedChannel() = 0;
177 
181  virtual void FailHijackedRecvMessage() = 0;
182 
185  virtual void FailHijackedSendMessage() = 0;
186 };
187 
190 class Interceptor {
191  public:
192  virtual ~Interceptor() {}
193 
196  virtual void Intercept(InterceptorBatchMethods* methods) = 0;
197 };
198 
199 } // namespace experimental
200 } // namespace grpc
201 
202 #endif // GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H
virtual ~InterceptorBatchMethods()
Definition: interceptor.h:89
Class that is passed as an argument to the Intercept method of the application&#39;s Interceptor interfac...
Definition: interceptor.h:87
The first three in this list are for clients and servers.
::google::protobuf::util::Status Status
Definition: config_protobuf.h:93
InterceptionHookPoints
An enumeration of different possible points at which the Intercept method of the Interceptor interfac...
Definition: interceptor.h:48
The following three are for hijacked clients only and can only be registered by the global intercepto...
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
Interface for an interceptor.
Definition: interceptor.h:190
virtual ~Interceptor()
Definition: interceptor.h:192
This is a special hook point available to both clients and servers when TryCancel() is performed...
Did it work? If it didn&#39;t, why?
Definition: status.h:31
A sequence of bytes.
Definition: byte_buffer.h:64
The following two are for all clients and servers.