Fix broken tests

pull/18374/head
Karthik Ravi Shankar 6 years ago
parent 29bcbb24c2
commit 4a0c3b848f
  1. 2
      examples/BUILD
  2. 30
      include/grpcpp/create_channel.h
  3. 18
      include/grpcpp/create_channel_impl.h
  4. 31
      include/grpcpp/security/credentials.h
  5. 38
      src/cpp/client/create_channel.cc

@ -112,4 +112,4 @@ cc_binary(
srcs = ["cpp/keyvaluestore/server.cc"],
defines = ["BAZEL_BUILD"],
deps = [":keyvaluestore", "//:grpc++"],
)
)

@ -21,4 +21,34 @@
#include <grpcpp/create_channel_impl.h>
namespace grpc {
static inline std::shared_ptr<Channel> CreateChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds) {
return ::grpc_impl::CreateChannel(target, creds);
}
static inline std::shared_ptr<Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args) {
return ::grpc_impl::CreateCustomChannel(target, creds, args);
}
namespace experimental {
static inline std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) {
return ::grpc_impl::experimental::CreateCustomChannelWithInterceptors(target, creds, args, std::move(interceptor_creators));
}
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_CREATE_CHANNEL_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<Channel> CreateChannel(
std::shared_ptr<grpc::Channel> CreateChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds);
const std::shared_ptr<grpc::ChannelCredentials>& creds);
/// Create a new \em custom \a Channel pointing to \a target.
///
@ -49,10 +49,10 @@ std::shared_ptr<Channel> 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<Channel> CreateCustomChannel(
std::shared_ptr<grpc::Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args);
const std::shared_ptr<grpc::ChannelCredentials>& 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<Channel> CreateCustomChannelWithInterceptors(
std::shared_ptr<grpc::Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args,
std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);
} // namespace experimental
} // namespace grpc_impl

@ -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<grpc::Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args);
namespace experimental {
std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
std::shared_ptr<grpc::Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args,
std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
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<Channel> CreateCustomChannel(
friend std::shared_ptr<Channel> grpc_impl::CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args);
friend std::shared_ptr<Channel>
experimental::CreateCustomChannelWithInterceptors(
grpc_impl::experimental::CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,

@ -19,34 +19,36 @@
#include <memory>
#include <grpcpp/channel.h>
#include <grpcpp/create_channel.h>
#include <grpcpp/create_channel_impl.h>
#include <grpcpp/impl/grpc_library.h>
#include <grpcpp/support/channel_arguments.h>
#include "src/cpp/client/create_channel_internal.h"
namespace grpc {
class ChannelArguments;
std::shared_ptr<Channel> CreateChannel(
class ChannelArguments;
}
namespace grpc_impl {
std::shared_ptr<grpc::Channel> CreateChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds) {
return CreateCustomChannel(target, creds, ChannelArguments());
const std::shared_ptr<grpc::ChannelCredentials>& creds) {
return CreateCustomChannel(target, creds, grpc::ChannelArguments());
}
std::shared_ptr<Channel> CreateCustomChannel(
std::shared_ptr<grpc::Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args) {
GrpcLibraryCodegen init_lib; // We need to call init in case of a bad creds.
const std::shared_ptr<grpc::ChannelCredentials>& 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<std::unique_ptr<
experimental::ClientInterceptorFactoryInterface>>());
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<Channel> CreateCustomChannelWithInterceptors(
std::shared_ptr<grpc::Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args,
std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
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<std::unique_ptr<
experimental::ClientInterceptorFactoryInterface>>());
grpc::experimental::ClientInterceptorFactoryInterface>>());
}
} // namespace experimental
} // namespace grpc
} // namespace grpc_impl

Loading…
Cancel
Save