6 #ifndef swcdb_thrift_client_Client_h
7 #define swcdb_thrift_client_Client_h
32 #include <thrift/transport/TSocket.h>
33 #include <thrift/transport/TTransportUtils.h>
34 #include <thrift/transport/TZlibTransport.h>
35 #include <thrift/protocol/TBinaryProtocol.h>
37 #include "swcdb/thrift/gen-cpp/Service.h"
42 namespace thrift = apache::thrift;
49 const uint32_t timeout,
bool open=
true) {
50 auto sock =
new thrift::transport::TSocket(host, port);
51 sock->setConnTimeout(timeout);
52 sock->setSendTimeout(timeout);
53 sock->setRecvTimeout(timeout);
73 try {
close(); }
catch(...) {}
78 std::shared_ptr<thrift::transport::TTransport>
socket;
79 std::shared_ptr<thrift::transport::TTransport>
transport;
80 std::shared_ptr<thrift::protocol::TProtocol>
protocol;
86 typedef std::shared_ptr<Client>
Ptr;
88 static Ptr make(
const std::string& host,
const uint16_t port,
93 Client(
const std::string& host,
const uint16_t port,
107 #ifdef SWC_IMPL_SOURCE
108 #include "swcdb/thrift/gen-cpp/Service.cpp"
109 #include "swcdb/thrift/gen-cpp/Service_types.cpp"
114 #endif // swcdb_thrift_client_Client_h