From 8ae3a250dd2ab9b830d1cde8348eb86328172a2c Mon Sep 17 00:00:00 2001 From: arches Date: Tue, 21 Jun 2016 10:58:24 -0400 Subject: [PATCH] Remove AsyncPutResponse, utils and grpcClient --- src/CMakeLists.txt | 2 +- src/Client.cpp | 1 - v3/include/AsyncPutResponse.hpp | 36 -------------------------- v3/include/AsyncRangeResponse.hpp | 1 - v3/include/Utils.hpp | 15 ----------- v3/include/grpcClient.hpp | 25 ------------------ v3/src/AsyncPutResponse.cpp | 43 ------------------------------- v3/src/Utils.cpp | 24 ----------------- v3/src/grpcClient.cpp | 14 ---------- 9 files changed, 1 insertion(+), 160 deletions(-) delete mode 100644 v3/include/AsyncPutResponse.hpp delete mode 100644 v3/include/Utils.hpp delete mode 100644 v3/include/grpcClient.hpp delete mode 100644 v3/src/AsyncPutResponse.cpp delete mode 100644 v3/src/Utils.cpp delete mode 100644 v3/src/grpcClient.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce09f41..98eab76 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(etcd-cpp-api SHARED ../proto/kv.pb.cc ../proto/auth.pb.cc ../proto/rpc.pb.cc ../proto/rpc.grpc.pb.cc ../v3/src/Utils.cpp ../v3/src/grpcClient.cpp ../v3/src/AsyncTxnResponse.cpp ../v3/src/AsyncRangeResponse.cpp ../v3/src/AsyncPutResponse.cpp ../v3/src/AsyncWatchResponse.cpp ../v3/src/Transaction.cpp 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 ../v3/src/AsyncTxnResponse.cpp ../v3/src/AsyncRangeResponse.cpp ../v3/src/AsyncWatchResponse.cpp ../v3/src/Transaction.cpp 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 protobuf grpc++) diff --git a/src/Client.cpp b/src/Client.cpp index 8854b91..4a80b91 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -3,7 +3,6 @@ #include "v3/include/AsyncTxnResponse.hpp" #include "v3/include/AsyncRangeResponse.hpp" #include "v3/include/AsyncWatchResponse.hpp" -#include "v3/include/Utils.hpp" #include "v3/include/Transaction.hpp" #include diff --git a/v3/include/AsyncPutResponse.hpp b/v3/include/AsyncPutResponse.hpp deleted file mode 100644 index 8145f5e..0000000 --- a/v3/include/AsyncPutResponse.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __ASYNC_PUTRESPONSE_HPP__ -#define __ASYNC_PUTRESPONSE_HPP__ - -#include -#include "proto/rpc.grpc.pb.h" -#include "v3/include/V3Response.hpp" -#include "v3/include/grpcClient.hpp" - - -using grpc::ClientAsyncResponseReader; -using grpc::ClientContext; -using grpc::CompletionQueue; -using grpc::Status; -using etcdserverpb::PutResponse; - -namespace etcdv3 -{ - class AsyncPutResponse : public etcdv3::V3Response - { - public: - AsyncPutResponse(){}; - AsyncPutResponse(const std::string act){action = act;}; - AsyncPutResponse(const AsyncPutResponse& other); - AsyncPutResponse& operator=(const AsyncPutResponse& other); - PutResponse reply; - Status status; - ClientContext context; - CompletionQueue cq_; - std::unique_ptr> response_reader; - AsyncPutResponse& ParseResponse(); - etcdv3::grpcClient* client; - std::string key; - }; -} - -#endif diff --git a/v3/include/AsyncRangeResponse.hpp b/v3/include/AsyncRangeResponse.hpp index 66d6cae..3de0294 100644 --- a/v3/include/AsyncRangeResponse.hpp +++ b/v3/include/AsyncRangeResponse.hpp @@ -23,7 +23,6 @@ namespace etcdv3 AsyncRangeResponse& ParseResponse(); void waitForResponse(); RangeResponse reply; - etcdserverpb::PutResponse r; Status status; ClientContext context; CompletionQueue cq_; diff --git a/v3/include/Utils.hpp b/v3/include/Utils.hpp deleted file mode 100644 index 587c6ee..0000000 --- a/v3/include/Utils.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __UTILS_HPP__ -#define __UTILS_HPP__ - -#include "v3/include/AsyncRangeResponse.hpp" -#include "v3/include/grpcClient.hpp" - -namespace etcdv3 -{ - namespace Utils - { - etcdv3::AsyncRangeResponse* getKey(std::string const & key, etcdv3::grpcClient& client); - } -} -#endif - diff --git a/v3/include/grpcClient.hpp b/v3/include/grpcClient.hpp deleted file mode 100644 index 9795b11..0000000 --- a/v3/include/grpcClient.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __GRPC_CLIENT_HPP__ -#define __GRPC_CLIENT_HPP__ - -#include -#include "proto/rpc.grpc.pb.h" -#include "v3/include/AsyncRangeResponse.hpp" - - -using grpc::Channel; -using etcdserverpb::PutRequest; -using etcdserverpb::RangeRequest; -using etcdserverpb::KV; - -namespace etcdv3 -{ - - class grpcClient - { - public: - grpcClient(std::string const & address); - std::unique_ptr stub_; - }; -} - -#endif diff --git a/v3/src/AsyncPutResponse.cpp b/v3/src/AsyncPutResponse.cpp deleted file mode 100644 index 709edda..0000000 --- a/v3/src/AsyncPutResponse.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "v3/include/AsyncPutResponse.hpp" -#include "v3/include/Utils.hpp" - -#include - -using etcdserverpb::PutRequest; -using etcdserverpb::PutRequest; - -etcdv3::AsyncPutResponse::AsyncPutResponse(const etcdv3::AsyncPutResponse& other) -{ - error_code = other.error_code; - error_message = other.error_message; - index = other.index; - action = other.action; - values = other.values; - prev_values= other.prev_values; - -} - -etcdv3::AsyncPutResponse& etcdv3::AsyncPutResponse::operator=(const etcdv3::AsyncPutResponse& other) -{ - error_code = other.error_code; - error_message = other.error_message; - index = other.index; - action = other.action; - values = other.values; - prev_values= other.prev_values; - return *this; -} - -etcdv3::AsyncPutResponse& etcdv3::AsyncPutResponse::ParseResponse() -{ - etcdv3::AsyncRangeResponse* resp = etcdv3::Utils::getKey(key, *client); - if(resp->reply.kvs_size()) - { - values.push_back(resp->reply.kvs(0)); - index = resp->reply.kvs(0).create_revision(); - } - else - index = resp->reply.header().revision(); - - return *this; -} diff --git a/v3/src/Utils.cpp b/v3/src/Utils.cpp deleted file mode 100644 index a769d0b..0000000 --- a/v3/src/Utils.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "v3/include/AsyncRangeResponse.hpp" -#include "proto/rpc.grpc.pb.h" -using etcdserverpb::RangeRequest; - -#include "v3/include/Utils.hpp" - - -etcdv3::AsyncRangeResponse* etcdv3::Utils::getKey(std::string const & key, etcdv3::grpcClient& client) -{ - RangeRequest get_request; - get_request.set_key(key); - etcdv3::AsyncRangeResponse* resp= new etcdv3::AsyncRangeResponse(); - - resp->status = client.stub_->Range(&resp->context, get_request, &resp->reply); - - if(resp->status.ok()) - { - return resp; - } - else - { - throw std::runtime_error(resp->status.error_message()); - } -} diff --git a/v3/src/grpcClient.cpp b/v3/src/grpcClient.cpp deleted file mode 100644 index 7fd37d9..0000000 --- a/v3/src/grpcClient.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "v3/include/grpcClient.hpp" - -etcdv3::grpcClient::grpcClient(std::string const & 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 = grpc::CreateChannel(stripped_address, grpc::InsecureChannelCredentials()); - stub_= KV::NewStub(channel); -}