diff options
author | Yash Tibrewal <yashkt@google.com> | 2018-10-22 02:42:03 -0700 |
---|---|---|
committer | Yash Tibrewal <yashkt@google.com> | 2018-10-22 02:42:03 -0700 |
commit | 9b83b7d19e0a3e14dbfca2f40fa8157547c190f4 (patch) | |
tree | 8e48f2a77de1b44cd9415f5d6b11aa452095861d /include/grpcpp/impl/codegen/client_interceptor.h | |
parent | 3a17f5b05ec6adce638fd03168a923e727759969 (diff) |
Adding intercepted channel
Diffstat (limited to 'include/grpcpp/impl/codegen/client_interceptor.h')
-rw-r--r-- | include/grpcpp/impl/codegen/client_interceptor.h | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/include/grpcpp/impl/codegen/client_interceptor.h b/include/grpcpp/impl/codegen/client_interceptor.h index 06f009e7d3..8f32814838 100644 --- a/include/grpcpp/impl/codegen/client_interceptor.h +++ b/include/grpcpp/impl/codegen/client_interceptor.h @@ -46,16 +46,7 @@ class ClientInterceptorFactoryInterface { class ClientRpcInfo { public: ClientRpcInfo() {} - ClientRpcInfo(grpc::ClientContext* ctx, const char* method, - grpc::Channel* channel, - const std::vector<std::unique_ptr< - experimental::ClientInterceptorFactoryInterface>>& creators) - : ctx_(ctx), method_(method), channel_(channel) { - for (const auto& creator : creators) { - interceptors_.push_back(std::unique_ptr<experimental::Interceptor>( - creator->CreateClientInterceptor(this))); - } - } + ~ClientRpcInfo(){}; ClientRpcInfo(const ClientRpcInfo&) = delete; @@ -67,7 +58,10 @@ class ClientRpcInfo { Channel* channel() { return channel_; } grpc::ClientContext* client_context() { return ctx_; } - public: + private: + ClientRpcInfo(grpc::ClientContext* ctx, const char* method, + grpc::Channel* channel) + : ctx_(ctx), method_(method), channel_(channel) {} // Runs interceptor at pos \a pos. void RunInterceptor( experimental::InterceptorBatchMethods* interceptor_methods, @@ -76,7 +70,17 @@ class ClientRpcInfo { interceptors_[pos]->Intercept(interceptor_methods); } - private: + void RegisterInterceptors( + const std::vector<std::unique_ptr< + experimental::ClientInterceptorFactoryInterface>>& creators, + int interceptor_pos) { + for (auto it = creators.begin() + interceptor_pos; it != creators.end(); + ++it) { + interceptors_.push_back(std::unique_ptr<experimental::Interceptor>( + (*it)->CreateClientInterceptor(this))); + } + } + grpc::ClientContext* ctx_ = nullptr; const char* method_ = nullptr; grpc::Channel* channel_ = nullptr; @@ -85,6 +89,7 @@ class ClientRpcInfo { int hijacked_interceptor_ = false; friend class internal::InterceptorBatchMethodsImpl; + friend class grpc::ClientContext; }; } // namespace experimental |