diff --git a/examples/BUILD b/examples/BUILD index 0a1ca94a649..c67c582964a 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -112,4 +112,4 @@ cc_binary( srcs = ["cpp/keyvaluestore/server.cc"], defines = ["BAZEL_BUILD"], deps = [":keyvaluestore", "//:grpc++"], -) \ No newline at end of file +) diff --git a/include/grpcpp/create_channel.h b/include/grpcpp/create_channel.h index 40d4717071a..7d92716b773 100644 --- a/include/grpcpp/create_channel.h +++ b/include/grpcpp/create_channel.h @@ -21,4 +21,34 @@ #include +namespace grpc { + +static inline std::shared_ptr CreateChannel( + const grpc::string& target, + const std::shared_ptr& creds) { + return ::grpc_impl::CreateChannel(target, creds); +} + +static inline std::shared_ptr CreateCustomChannel( + const grpc::string& target, + const std::shared_ptr& creds, + const ChannelArguments& args) { + return ::grpc_impl::CreateCustomChannel(target, creds, args); +} + +namespace experimental { + +static inline std::shared_ptr CreateCustomChannelWithInterceptors( + const grpc::string& target, + const std::shared_ptr& creds, + const ChannelArguments& args, + std::vector< + std::unique_ptr> + interceptor_creators) { + return ::grpc_impl::experimental::CreateCustomChannelWithInterceptors(target, creds, args, std::move(interceptor_creators)); +} + +} // namespace experimental +} // namespace grpc + #endif // GRPCPP_CREATE_CHANNEL_H diff --git a/include/grpcpp/create_channel_impl.h b/include/grpcpp/create_channel_impl.h index 9eaeb7c17f6..214a537a3cb 100644 --- a/include/grpcpp/create_channel_impl.h +++ b/include/grpcpp/create_channel_impl.h @@ -35,9 +35,9 @@ namespace grpc_impl { /// \param creds Credentials to use for the created channel. If it does not /// hold an object or is invalid, a lame channel (one on which all operations /// fail) is returned. -std::shared_ptr CreateChannel( +std::shared_ptr CreateChannel( const grpc::string& target, - const std::shared_ptr& creds); + const std::shared_ptr& creds); /// Create a new \em custom \a Channel pointing to \a target. /// @@ -49,10 +49,10 @@ std::shared_ptr CreateChannel( /// hold an object or is invalid, a lame channel (one on which all operations /// fail) is returned. /// \param args Options for channel creation. -std::shared_ptr CreateCustomChannel( +std::shared_ptr CreateCustomChannel( const grpc::string& target, - const std::shared_ptr& creds, - const ChannelArguments& args); + const std::shared_ptr& creds, + const grpc::ChannelArguments& args); namespace experimental { /// Create a new \em custom \a Channel pointing to \a target with \a @@ -66,12 +66,12 @@ namespace experimental { /// hold an object or is invalid, a lame channel (one on which all operations /// fail) is returned. /// \param args Options for channel creation. -std::shared_ptr CreateCustomChannelWithInterceptors( +std::shared_ptr CreateCustomChannelWithInterceptors( const grpc::string& target, - const std::shared_ptr& creds, - const ChannelArguments& args, + const std::shared_ptr& creds, + const grpc::ChannelArguments& args, std::vector< - std::unique_ptr> + std::unique_ptr> interceptor_creators); } // namespace experimental } // namespace grpc_impl diff --git a/include/grpcpp/security/credentials.h b/include/grpcpp/security/credentials.h index dfea3900048..f17e295975a 100644 --- a/include/grpcpp/security/credentials.h +++ b/include/grpcpp/security/credentials.h @@ -33,23 +33,32 @@ struct grpc_call; namespace grpc { -class ChannelArguments; -class Channel; -class SecureChannelCredentials; -class CallCredentials; -class SecureCallCredentials; +class CallCredentials; +class ChannelArguments; class ChannelCredentials; +} +namespace grpc_impl { +std::shared_ptr CreateCustomChannel( + const grpc::string& target, + const std::shared_ptr& creds, + const grpc::ChannelArguments& args); namespace experimental { -std::shared_ptr CreateCustomChannelWithInterceptors( +std::shared_ptr CreateCustomChannelWithInterceptors( const grpc::string& target, - const std::shared_ptr& creds, - const ChannelArguments& args, + const std::shared_ptr& creds, + const grpc::ChannelArguments& args, std::vector< - std::unique_ptr> + std::unique_ptr> interceptor_creators); } // namespace experimental +} // namespace grpc_impl +namespace grpc { +class Channel; +class SecureChannelCredentials; +class SecureCallCredentials; + /// A channel credentials object encapsulates all the state needed by a client /// to authenticate with a server for a given channel. @@ -70,13 +79,13 @@ class ChannelCredentials : private GrpcLibraryCodegen { virtual SecureChannelCredentials* AsSecureCredentials() = 0; private: - friend std::shared_ptr CreateCustomChannel( + friend std::shared_ptr grpc_impl::CreateCustomChannel( const grpc::string& target, const std::shared_ptr& creds, const ChannelArguments& args); friend std::shared_ptr - experimental::CreateCustomChannelWithInterceptors( + grpc_impl::experimental::CreateCustomChannelWithInterceptors( const grpc::string& target, const std::shared_ptr& creds, const ChannelArguments& args, diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc index 457daa674c7..4a4298684cb 100644 --- a/src/cpp/client/create_channel.cc +++ b/src/cpp/client/create_channel.cc @@ -19,34 +19,36 @@ #include #include -#include +#include #include #include #include "src/cpp/client/create_channel_internal.h" namespace grpc { -class ChannelArguments; -std::shared_ptr CreateChannel( +class ChannelArguments; +} +namespace grpc_impl { +std::shared_ptr CreateChannel( const grpc::string& target, - const std::shared_ptr& creds) { - return CreateCustomChannel(target, creds, ChannelArguments()); + const std::shared_ptr& creds) { + return CreateCustomChannel(target, creds, grpc::ChannelArguments()); } -std::shared_ptr CreateCustomChannel( +std::shared_ptr CreateCustomChannel( const grpc::string& target, - const std::shared_ptr& creds, - const ChannelArguments& args) { - GrpcLibraryCodegen init_lib; // We need to call init in case of a bad creds. + const std::shared_ptr& creds, + const grpc::ChannelArguments& args) { + grpc::GrpcLibraryCodegen init_lib; // We need to call init in case of a bad creds. return creds ? creds->CreateChannel(target, args) - : CreateChannelInternal( + : grpc::CreateChannelInternal( "", grpc_lame_client_channel_create( nullptr, GRPC_STATUS_INVALID_ARGUMENT, "Invalid credentials."), std::vector>()); + grpc::experimental::ClientInterceptorFactoryInterface>>()); } namespace experimental { @@ -61,23 +63,23 @@ namespace experimental { /// hold an object or is invalid, a lame channel (one on which all operations /// fail) is returned. /// \param args Options for channel creation. -std::shared_ptr CreateCustomChannelWithInterceptors( +std::shared_ptr CreateCustomChannelWithInterceptors( const grpc::string& target, - const std::shared_ptr& creds, - const ChannelArguments& args, + const std::shared_ptr& creds, + const grpc::ChannelArguments& args, std::vector< - std::unique_ptr> + std::unique_ptr> interceptor_creators) { return creds ? creds->CreateChannelWithInterceptors( target, args, std::move(interceptor_creators)) - : CreateChannelInternal( + : grpc::CreateChannelInternal( "", grpc_lame_client_channel_create( nullptr, GRPC_STATUS_INVALID_ARGUMENT, "Invalid credentials."), std::vector>()); + grpc::experimental::ClientInterceptorFactoryInterface>>()); } } // namespace experimental -} // namespace grpc +} // namespace grpc_impl