Remove check and useless compatibility for older gRPC.
Signed-off-by: Tao He <sighingnow@gmail.com>
This commit is contained in:
parent
fe80439c5b
commit
f1cc2f0459
|
|
@ -122,6 +122,7 @@ else()
|
|||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindGRPC.cmake)
|
||||
set(GRPC_LIBRARIES ${GPR_LIBRARY} ${GRPC_LIBRARY} ${GRPC_GRPC++_LIBRARY})
|
||||
endif()
|
||||
message("-- Found GRPC: ${GRPC_LIBRARIES} (found version: \"${gRPC_VERSION}\")")
|
||||
# avoid use the apt-get installed libgrpc-dev (version v1.13) on Ubuntu 18.04
|
||||
if(gRPC_FOUND AND gRPC_VERSION VERSION_LESS "1.14")
|
||||
message(FATAL_ERROR "gRPC '${gRPC_VERSION}' is not supported, please install a newer gRPC library "
|
||||
|
|
@ -152,20 +153,6 @@ check_cxx_compiler_flag(-Wno-c++17-extensions W_NO_CPP17_EXTENSIONS)
|
|||
if(W_NO_CPP17_EXTENSIONS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++17-extensions")
|
||||
endif()
|
||||
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11")
|
||||
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${GRPC_INCLUDE_DIR}")
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} ${GRPC_LIBRARIES}")
|
||||
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
|
||||
check_cxx_source_compiles("
|
||||
#include <grpc++/grpc++.h>
|
||||
namespace grpc { class Channel; }
|
||||
int main() {}
|
||||
" GRPC_CHANNEL_CLASS_FOUND)
|
||||
if(GRPC_CHANNEL_CLASS_FOUND)
|
||||
add_definitions(-DWITH_GRPC_CHANNEL_CLASS)
|
||||
endif()
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
|
|
|||
|
|
@ -55,12 +55,7 @@ namespace etcd
|
|||
* @param arguments user provided grpc channel arguments.
|
||||
*/
|
||||
Client(std::string const & etcd_url,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
);
|
||||
grpc::ChannelArguments const & arguments);
|
||||
|
||||
/**
|
||||
* Constructs an etcd client object.
|
||||
|
|
@ -80,12 +75,7 @@ namespace etcd
|
|||
* @param arguments user provided grpc channel arguments.
|
||||
*/
|
||||
static Client *WithUrl(std::string const & etcd_url,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
);
|
||||
grpc::ChannelArguments const & arguments);
|
||||
|
||||
/**
|
||||
* Constructs an etcd client object.
|
||||
|
|
@ -118,12 +108,7 @@ namespace etcd
|
|||
std::string const & username,
|
||||
std::string const & password,
|
||||
int const auth_token_ttl,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
);
|
||||
grpc::ChannelArguments const & arguments);
|
||||
|
||||
/**
|
||||
* Constructs an etcd client object.
|
||||
|
|
@ -156,12 +141,7 @@ namespace etcd
|
|||
std::string const & username,
|
||||
std::string const & password,
|
||||
int const auth_token_ttl,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
);
|
||||
grpc::ChannelArguments const & arguments);
|
||||
|
||||
/**
|
||||
* Constructs an etcd client object.
|
||||
|
|
@ -195,12 +175,7 @@ namespace etcd
|
|||
std::string const & cert,
|
||||
std::string const & privkey,
|
||||
std::string const & target_name_override,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
);
|
||||
grpc::ChannelArguments const & arguments);
|
||||
|
||||
/**
|
||||
* Constructs an etcd client object.
|
||||
|
|
@ -236,15 +211,11 @@ namespace etcd
|
|||
* @param arguments user provided grpc channel arguments.
|
||||
*/
|
||||
static Client *WithSSL(std::string const & etcd_url,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments,
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments,
|
||||
#endif
|
||||
std::string const & ca,
|
||||
std::string const & cert = "",
|
||||
std::string const & privkey = "",
|
||||
std::string const & target_name_override = "");
|
||||
grpc::ChannelArguments const & arguments,
|
||||
std::string const & ca,
|
||||
std::string const & cert = "",
|
||||
std::string const & privkey = "",
|
||||
std::string const & target_name_override = "");
|
||||
|
||||
~Client();
|
||||
|
||||
|
|
@ -683,11 +654,7 @@ namespace etcd
|
|||
/**
|
||||
* Obtain the underlying gRPC channel.
|
||||
*/
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
std::shared_ptr<grpc::Channel> grpc_channel() const;
|
||||
#else
|
||||
std::shared_ptr<grpc_impl::Channel> grpc_channel() const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set a timeout value for grpc operations.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace etcdv3 {
|
||||
struct ActionParameters;
|
||||
|
||||
|
||||
class AsyncCompareAndDeleteAction;
|
||||
class AsyncCompareAndSwapAction;
|
||||
class AsyncDeleteAction;
|
||||
|
|
@ -45,17 +45,10 @@ namespace etcdv3 {
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
namespace grpc {
|
||||
class Channel;
|
||||
class ChannelArguments;
|
||||
}
|
||||
#else
|
||||
namespace grpc_impl {
|
||||
class Channel;
|
||||
class ChannelArguments;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace etcd
|
||||
{
|
||||
|
|
@ -108,12 +101,7 @@ namespace etcd
|
|||
* @param arguments user provided grpc channel arguments.
|
||||
*/
|
||||
SyncClient(std::string const & etcd_url,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
);
|
||||
grpc::ChannelArguments const & arguments);
|
||||
|
||||
/**
|
||||
* Constructs an etcd client object.
|
||||
|
|
@ -133,12 +121,7 @@ namespace etcd
|
|||
* @param arguments user provided grpc channel arguments.
|
||||
*/
|
||||
static SyncClient *WithUrl(std::string const & etcd_url,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
);
|
||||
grpc::ChannelArguments const & arguments);
|
||||
|
||||
/**
|
||||
* Constructs an etcd client object.
|
||||
|
|
@ -171,12 +154,7 @@ namespace etcd
|
|||
std::string const & username,
|
||||
std::string const & password,
|
||||
int const auth_token_ttl,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
);
|
||||
grpc::ChannelArguments const & arguments);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -210,12 +188,7 @@ namespace etcd
|
|||
std::string const & username,
|
||||
std::string const & password,
|
||||
int const auth_token_ttl,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
);
|
||||
grpc::ChannelArguments const & arguments);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -250,12 +223,7 @@ namespace etcd
|
|||
std::string const & cert,
|
||||
std::string const & privkey,
|
||||
std::string const & target_name_override,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
);
|
||||
grpc::ChannelArguments const & arguments);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -292,15 +260,11 @@ namespace etcd
|
|||
* @param arguments user provided grpc channel arguments.
|
||||
*/
|
||||
static SyncClient *WithSSL(std::string const & etcd_url,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments,
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments,
|
||||
#endif
|
||||
std::string const & ca,
|
||||
std::string const & cert = "",
|
||||
std::string const & privkey = "",
|
||||
std::string const & target_name_override = "");
|
||||
grpc::ChannelArguments const & arguments,
|
||||
std::string const & ca,
|
||||
std::string const & cert = "",
|
||||
std::string const & privkey = "",
|
||||
std::string const & target_name_override = "");
|
||||
|
||||
~SyncClient();
|
||||
|
||||
|
|
@ -758,11 +722,7 @@ namespace etcd
|
|||
/**
|
||||
* Obtain the underlying gRPC channel.
|
||||
*/
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
std::shared_ptr<grpc::Channel> grpc_channel() const;
|
||||
#else
|
||||
std::shared_ptr<grpc_impl::Channel> grpc_channel() const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set a timeout value for grpc operations.
|
||||
|
|
@ -780,11 +740,7 @@ namespace etcd
|
|||
}
|
||||
|
||||
private:
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
std::shared_ptr<grpc::Channel> channel;
|
||||
#else
|
||||
std::shared_ptr<grpc_impl::Channel> channel;
|
||||
#endif
|
||||
|
||||
mutable std::unique_ptr<TokenAuthenticator, TokenAuthenticatorDeleter> token_authenticator;
|
||||
mutable std::chrono::microseconds grpc_timeout = std::chrono::microseconds::zero();
|
||||
|
|
|
|||
|
|
@ -82,13 +82,7 @@ etcd::Client::Client(std::string const & address,
|
|||
}
|
||||
|
||||
etcd::Client::Client(std::string const & address,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
|
||||
)
|
||||
grpc::ChannelArguments const & arguments)
|
||||
{
|
||||
this->own_client = true;
|
||||
this->client = new SyncClient(address, arguments);
|
||||
|
|
@ -100,13 +94,7 @@ etcd::Client *etcd::Client::WithUrl(std::string const & etcd_url,
|
|||
}
|
||||
|
||||
etcd::Client *etcd::Client::WithUrl(std::string const & etcd_url,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
|
||||
) {
|
||||
grpc::ChannelArguments const & arguments) {
|
||||
return new etcd::Client(etcd_url, arguments);
|
||||
}
|
||||
|
||||
|
|
@ -124,13 +112,7 @@ etcd::Client::Client(std::string const & address,
|
|||
std::string const & username,
|
||||
std::string const & password,
|
||||
int const auth_token_ttl,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
|
||||
)
|
||||
grpc::ChannelArguments const & arguments)
|
||||
{
|
||||
this->own_client = true;
|
||||
this->client = new SyncClient(address, username, password, auth_token_ttl, arguments);
|
||||
|
|
@ -148,13 +130,7 @@ etcd::Client *etcd::Client::WithUser(std::string const & etcd_url,
|
|||
std::string const & username,
|
||||
std::string const & password,
|
||||
int const auth_token_ttl,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
|
||||
) {
|
||||
grpc::ChannelArguments const & arguments) {
|
||||
return new etcd::Client(etcd_url, username, password, auth_token_ttl, arguments);
|
||||
}
|
||||
|
||||
|
|
@ -175,13 +151,7 @@ etcd::Client::Client(std::string const & address,
|
|||
std::string const & cert,
|
||||
std::string const & privkey,
|
||||
std::string const & target_name_override,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
|
||||
)
|
||||
grpc::ChannelArguments const & arguments)
|
||||
{
|
||||
this->own_client = true;
|
||||
this->client = new SyncClient(address, ca, cert, privkey, target_name_override, arguments);
|
||||
|
|
@ -197,11 +167,7 @@ etcd::Client *etcd::Client::WithSSL(std::string const & etcd_url,
|
|||
}
|
||||
|
||||
etcd::Client *etcd::Client::WithSSL(std::string const & etcd_url,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments,
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments,
|
||||
#endif
|
||||
grpc::ChannelArguments const & arguments,
|
||||
std::string const & ca,
|
||||
std::string const & cert,
|
||||
std::string const & privkey,
|
||||
|
|
|
|||
|
|
@ -271,12 +271,7 @@ etcd::SyncClient::SyncClient(std::string const & address,
|
|||
}
|
||||
|
||||
etcd::SyncClient::SyncClient(std::string const & address,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
)
|
||||
grpc::ChannelArguments const & arguments)
|
||||
{
|
||||
// create channels
|
||||
std::string const addresses = etcd::detail::strip_and_resolve_addresses(address);
|
||||
|
|
@ -302,12 +297,7 @@ etcd::SyncClient *etcd::SyncClient::WithUrl(std::string const & etcd_url,
|
|||
}
|
||||
|
||||
etcd::SyncClient *etcd::SyncClient::WithUrl(std::string const & etcd_url,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
) {
|
||||
grpc::ChannelArguments const & arguments) {
|
||||
return new etcd::SyncClient(etcd_url, arguments);
|
||||
}
|
||||
|
||||
|
|
@ -342,13 +332,7 @@ etcd::SyncClient::SyncClient(std::string const & address,
|
|||
std::string const & username,
|
||||
std::string const & password,
|
||||
int const auth_token_ttl,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
|
||||
)
|
||||
grpc::ChannelArguments const & arguments)
|
||||
{
|
||||
// create channels
|
||||
std::string const addresses = etcd::detail::strip_and_resolve_addresses(address);
|
||||
|
|
@ -382,12 +366,7 @@ etcd::SyncClient *etcd::SyncClient::WithUser(std::string const & etcd_url,
|
|||
std::string const & username,
|
||||
std::string const & password,
|
||||
int const auth_token_ttl,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
) {
|
||||
grpc::ChannelArguments const & arguments) {
|
||||
return new etcd::SyncClient(etcd_url, username, password, auth_token_ttl, arguments);
|
||||
}
|
||||
|
||||
|
|
@ -427,13 +406,7 @@ etcd::SyncClient::SyncClient(std::string const & address,
|
|||
std::string const & cert,
|
||||
std::string const & privkey,
|
||||
std::string const & target_name_override,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments
|
||||
#endif
|
||||
|
||||
)
|
||||
grpc::ChannelArguments const & arguments)
|
||||
{
|
||||
// create channels
|
||||
std::string const addresses = etcd::detail::strip_and_resolve_addresses(address);
|
||||
|
|
@ -467,11 +440,7 @@ etcd::SyncClient *etcd::SyncClient::WithSSL(std::string const & etcd_url,
|
|||
}
|
||||
|
||||
etcd::SyncClient *etcd::SyncClient::WithSSL(std::string const & etcd_url,
|
||||
#if defined(WITH_GRPC_CHANNEL_CLASS)
|
||||
grpc::ChannelArguments const & arguments,
|
||||
#else
|
||||
grpc_impl::ChannelArguments const & arguments,
|
||||
#endif
|
||||
grpc::ChannelArguments const & arguments,
|
||||
std::string const & ca,
|
||||
std::string const & cert,
|
||||
std::string const & privkey,
|
||||
|
|
|
|||
Loading…
Reference in New Issue