Updated CMakeList to use protobuf and grpc++ libraries.
Updated client constructor to use gprc channels.
This commit is contained in:
parent
9d01aeb928
commit
b78da53aa3
|
|
@ -6,6 +6,12 @@
|
|||
#include <cpprest/http_client.h>
|
||||
#include <string>
|
||||
|
||||
#include <grpc++/grpc++.h>
|
||||
#include "proto/rpc.grpc.pb.h"
|
||||
|
||||
using grpc::Channel;
|
||||
using etcdserverpb::KV;
|
||||
|
||||
namespace etcd
|
||||
{
|
||||
/**
|
||||
|
|
@ -132,6 +138,8 @@ namespace etcd
|
|||
pplx::task<Response> send_put_request(web::http::uri_builder & uri, std::string const & key, std::string const & value);
|
||||
|
||||
web::http::client::http_client client;
|
||||
|
||||
std::unique_ptr<KV::Stub> stub_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
add_library(etcd-cpp-api SHARED Client.cpp Response.cpp Value.cpp json_constants.cpp)
|
||||
add_library(etcd-cpp-api SHARED ../proto/kv.pb.cc ../proto/auth.pb.cc ../proto/rpc.pb.cc ../proto/rpc.grpc.pb.cc Client.cpp Response.cpp Value.cpp json_constants.cpp)
|
||||
set_property(TARGET etcd-cpp-api PROPERTY CXX_STANDARD 11)
|
||||
|
||||
target_link_libraries(etcd-cpp-api ${CPPREST_LIB} boost_system ssl crypto)
|
||||
target_link_libraries(etcd-cpp-api ${CPPREST_LIB} boost_system ssl crypto protobuf grpc++)
|
||||
|
||||
install (TARGETS etcd-cpp-api DESTINATION lib)
|
||||
install (FILES ../etcd/Client.hpp
|
||||
|
|
|
|||
|
|
@ -3,6 +3,15 @@
|
|||
etcd::Client::Client(std::string const & address)
|
||||
: client(address)
|
||||
{
|
||||
std::string stripped_address(address);
|
||||
std::string substr("http://");
|
||||
std::string::size_type i = stripped_address.find(substr);
|
||||
if(i != std::string::npos)
|
||||
{
|
||||
stripped_address.erase(i,substr.length());
|
||||
}
|
||||
std::shared_ptr<Channel> channel = grpc::CreateChannel(stripped_address, grpc::InsecureChannelCredentials());
|
||||
stub_= KV::NewStub(channel);
|
||||
}
|
||||
|
||||
pplx::task<etcd::Response> etcd::Client::send_get_request(web::http::uri_builder & uri)
|
||||
|
|
|
|||
Loading…
Reference in New Issue