pull/17797/head
Nicolas "Pixel" Noble 6 years ago
parent b0e6cc9b5f
commit cabbd35014
  1. 29
      include/grpcpp/channel_impl.h
  2. 4
      include/grpcpp/impl/codegen/client_context.h
  3. 1
      include/grpcpp/impl/codegen/client_interceptor.h
  4. 1
      include/grpcpp/impl/codegen/completion_queue.h
  5. 1
      include/grpcpp/security/credentials.h
  6. 30
      src/cpp/client/channel_cc.cc
  7. 5
      src/cpp/client/client_context.cc
  8. 6
      src/cpp/client/create_channel_internal.cc
  9. 6
      src/cpp/client/create_channel_internal.h
  10. 1
      src/cpp/client/secure_credentials.h
  11. 1
      test/cpp/util/create_test_channel.h

@ -65,33 +65,33 @@ class Channel final : public ::grpc::ChannelInterface,
friend void experimental::ChannelResetConnectionBackoff(Channel* channel); friend void experimental::ChannelResetConnectionBackoff(Channel* channel);
friend std::shared_ptr<Channel> CreateChannelInternal( friend std::shared_ptr<Channel> CreateChannelInternal(
const grpc::string& host, grpc_channel* c_channel, const grpc::string& host, grpc_channel* c_channel,
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> ::grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators); interceptor_creators);
friend class ::grpc::internal::InterceptedChannel; friend class ::grpc::internal::InterceptedChannel;
Channel(const grpc::string& host, grpc_channel* c_channel, Channel(const grpc::string& host, grpc_channel* c_channel,
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> ::grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators); interceptor_creators);
::grpc::internal::Call CreateCall(const ::grpc::internal::RpcMethod& method, ::grpc::internal::Call CreateCall(const ::grpc::internal::RpcMethod& method,
::grpc::ClientContext* context, ::grpc::ClientContext* context,
::grpc::CompletionQueue* cq) override; ::grpc::CompletionQueue* cq) override;
void PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, void PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops,
::grpc::internal::Call* call) override; ::grpc::internal::Call* call) override;
void* RegisterMethod(const char* method) override; void* RegisterMethod(const char* method) override;
void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
gpr_timespec deadline, ::grpc::CompletionQueue* cq, gpr_timespec deadline,
void* tag) override; ::grpc::CompletionQueue* cq, void* tag) override;
bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
gpr_timespec deadline) override; gpr_timespec deadline) override;
::grpc::CompletionQueue* CallbackCQ() override; ::grpc::CompletionQueue* CallbackCQ() override;
::grpc::internal::Call CreateCallInternal(const ::grpc::internal::RpcMethod& method, ::grpc::internal::Call CreateCallInternal(
::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context,
size_t interceptor_pos) override; ::grpc::CompletionQueue* cq, size_t interceptor_pos) override;
const grpc::string host_; const grpc::string host_;
grpc_channel* const c_channel_; // owned grpc_channel* const c_channel_; // owned
@ -105,10 +105,11 @@ class Channel final : public ::grpc::ChannelInterface,
// shutdown callback tag (invoked when the CQ is fully shutdown). // shutdown callback tag (invoked when the CQ is fully shutdown).
::grpc::CompletionQueue* callback_cq_ = nullptr; ::grpc::CompletionQueue* callback_cq_ = nullptr;
std::vector<std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> std::vector<
std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators_; interceptor_creators_;
}; };
} // namespace grpc } // namespace grpc_impl
#endif // GRPCPP_CHANNEL_H #endif // GRPCPP_CHANNEL_IMPL_H

@ -59,7 +59,6 @@ struct grpc_call;
namespace grpc_impl { namespace grpc_impl {
class Channel; class Channel;
} }
namespace grpc { namespace grpc {
@ -428,7 +427,8 @@ class ClientContext {
} }
grpc_call* call() const { return call_; } grpc_call* call() const { return call_; }
void set_call(grpc_call* call, const std::shared_ptr<::grpc_impl::Channel>& channel); void set_call(grpc_call* call,
const std::shared_ptr<::grpc_impl::Channel>& channel);
experimental::ClientRpcInfo* set_client_rpc_info( experimental::ClientRpcInfo* set_client_rpc_info(
const char* method, internal::RpcMethod::RpcType type, const char* method, internal::RpcMethod::RpcType type,

@ -29,7 +29,6 @@
namespace grpc_impl { namespace grpc_impl {
class Channel; class Channel;
} }
namespace grpc { namespace grpc {

@ -44,7 +44,6 @@ struct grpc_completion_queue;
namespace grpc_impl { namespace grpc_impl {
class Channel; class Channel;
} }
namespace grpc { namespace grpc {

@ -35,7 +35,6 @@ struct grpc_call;
namespace grpc_impl { namespace grpc_impl {
class Channel; class Channel;
} }
namespace grpc { namespace grpc {

@ -49,18 +49,18 @@
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
#include "src/core/lib/surface/completion_queue.h" #include "src/core/lib/surface/completion_queue.h"
void grpc::experimental::ChannelResetConnectionBackoff(::grpc::Channel* channel) { void grpc::experimental::ChannelResetConnectionBackoff(
::grpc::Channel* channel) {
ChannelResetConnectionBackoff(channel); ChannelResetConnectionBackoff(channel);
} }
namespace grpc_impl { namespace grpc_impl {
static ::grpc::internal::GrpcLibraryInitializer g_gli_initializer; static ::grpc::internal::GrpcLibraryInitializer g_gli_initializer;
Channel::Channel( Channel::Channel(const grpc::string& host, grpc_channel* channel,
const grpc::string& host, grpc_channel* channel, std::vector<std::unique_ptr<
std::vector< ::grpc::experimental::ClientInterceptorFactoryInterface>>
std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> interceptor_creators)
interceptor_creators)
: host_(host), c_channel_(channel) { : host_(host), c_channel_(channel) {
interceptor_creators_ = std::move(interceptor_creators); interceptor_creators_ = std::move(interceptor_creators);
g_gli_initializer.summon(); g_gli_initializer.summon();
@ -76,7 +76,8 @@ Channel::~Channel() {
namespace { namespace {
inline grpc_slice SliceFromArray(const char* arr, size_t len) { inline grpc_slice SliceFromArray(const char* arr, size_t len) {
return ::grpc::g_core_codegen_interface->grpc_slice_from_copied_buffer(arr, len); return ::grpc::g_core_codegen_interface->grpc_slice_from_copied_buffer(arr,
len);
} }
grpc::string GetChannelInfoField(grpc_channel* channel, grpc::string GetChannelInfoField(grpc_channel* channel,
@ -114,10 +115,9 @@ void ChannelResetConnectionBackoff(Channel* channel) {
} // namespace experimental } // namespace experimental
::grpc::internal::Call Channel::CreateCallInternal(const ::grpc::internal::RpcMethod& method, ::grpc::internal::Call Channel::CreateCallInternal(
::grpc::ClientContext* context, const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context,
::grpc::CompletionQueue* cq, ::grpc::CompletionQueue* cq, size_t interceptor_pos) {
size_t interceptor_pos) {
const bool kRegistered = method.channel_tag() && context->authority().empty(); const bool kRegistered = method.channel_tag() && context->authority().empty();
grpc_call* c_call = nullptr; grpc_call* c_call = nullptr;
if (kRegistered) { if (kRegistered) {
@ -161,9 +161,9 @@ void ChannelResetConnectionBackoff(Channel* channel) {
return ::grpc::internal::Call(c_call, this, cq, info); return ::grpc::internal::Call(c_call, this, cq, info);
} }
::grpc::internal::Call Channel::CreateCall(const ::grpc::internal::RpcMethod& method, ::grpc::internal::Call Channel::CreateCall(
::grpc::ClientContext* context, const ::grpc::internal::RpcMethod& method, ::grpc::ClientContext* context,
::grpc::CompletionQueue* cq) { ::grpc::CompletionQueue* cq) {
return CreateCallInternal(method, context, cq, 0); return CreateCallInternal(method, context, cq, 0);
} }
@ -256,4 +256,4 @@ class ShutdownCallback : public grpc_experimental_completion_queue_functor {
return callback_cq_; return callback_cq_;
} }
} // namespace grpc } // namespace grpc_impl

@ -33,7 +33,6 @@
namespace grpc_impl { namespace grpc_impl {
class Channel; class Channel;
} }
namespace grpc { namespace grpc {
@ -88,8 +87,8 @@ void ClientContext::AddMetadata(const grpc::string& meta_key,
send_initial_metadata_.insert(std::make_pair(meta_key, meta_value)); send_initial_metadata_.insert(std::make_pair(meta_key, meta_value));
} }
void ClientContext::set_call(grpc_call* call, void ClientContext::set_call(
const std::shared_ptr<::grpc_impl::Channel>& channel) { grpc_call* call, const std::shared_ptr<::grpc_impl::Channel>& channel) {
std::unique_lock<std::mutex> lock(mu_); std::unique_lock<std::mutex> lock(mu_);
GPR_ASSERT(call_ == nullptr); GPR_ASSERT(call_ == nullptr);
call_ = call; call_ = call;

@ -26,11 +26,11 @@ namespace grpc_impl {
std::shared_ptr<Channel> CreateChannelInternal( std::shared_ptr<Channel> CreateChannelInternal(
const grpc::string& host, grpc_channel* c_channel, const grpc::string& host, grpc_channel* c_channel,
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> ::grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) { interceptor_creators) {
return std::shared_ptr<Channel>( return std::shared_ptr<Channel>(
new Channel(host, c_channel, std::move(interceptor_creators))); new Channel(host, c_channel, std::move(interceptor_creators)));
} }
} } // namespace grpc_impl

@ -32,10 +32,10 @@ class Channel;
std::shared_ptr<Channel> CreateChannelInternal( std::shared_ptr<Channel> CreateChannelInternal(
const grpc::string& host, grpc_channel* c_channel, const grpc::string& host, grpc_channel* c_channel,
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<::grpc::experimental::ClientInterceptorFactoryInterface>> ::grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators); interceptor_creators);
} // namespace grpc } // namespace grpc_impl
#endif // GRPC_INTERNAL_CPP_CLIENT_CREATE_CHANNEL_INTERNAL_H #endif // GRPC_INTERNAL_CPP_CLIENT_CREATE_CHANNEL_INTERNAL_H

@ -30,7 +30,6 @@
namespace grpc_impl { namespace grpc_impl {
class Channel; class Channel;
} }
namespace grpc { namespace grpc {

@ -26,7 +26,6 @@
namespace grpc_impl { namespace grpc_impl {
class Channel; class Channel;
} }
namespace grpc { namespace grpc {

Loading…
Cancel
Save