OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThriftClient.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef THRIFTCLIENT_H
18 #define THRIFTCLIENT_H
19 #include <thrift/protocol/TBinaryProtocol.h>
20 #include <thrift/protocol/TJSONProtocol.h>
21 #include <thrift/transport/TBufferTransports.h>
22 #include <thrift/transport/THttpClient.h>
23 #include <thrift/transport/TSSLSocket.h>
24 #include <thrift/transport/TSocket.h>
25 #include <string>
26 
27 using namespace ::apache::thrift::transport;
28 using namespace ::apache::thrift::protocol;
29 using namespace ::apache::thrift::transport;
30 
32 
34  public:
35  ThriftClientConnection(const std::string& server_host,
36  const int port,
37  const ThriftConnectionType conn_type,
38  bool skip_host_verify,
39  const std::string& ca_cert_name,
40  const std::string& trust_cert_file)
41  : server_host_(server_host)
42  , port_(port)
43  , conn_type_(conn_type)
44  , skip_host_verify_(skip_host_verify)
45  , ca_cert_name_(ca_cert_name)
46  , trust_cert_file_(trust_cert_file){};
47 
48  ThriftClientConnection(const std::string& server_host,
49  const int port,
50  const ThriftConnectionType conn_type,
51  bool skip_host_verify,
52  std::shared_ptr<TSSLSocketFactory> factory);
53 
55 
56  std::shared_ptr<TTransport> open_buffered_client_transport(
57  const std::string& server_host,
58  const int port,
59  const std::string& ca_cert_name,
60  const bool with_timeout = false,
61  const bool with_keepalive = true,
62  const unsigned connect_timeout = 0,
63  const unsigned recv_timeount = 0,
64  const unsigned send_timeout = 0);
65 
66  std::shared_ptr<TTransport> open_http_client_transport(
67  const std::string& server_host,
68  const int port,
69  const std::string& trust_cert_file_,
70  bool use_https,
71  bool skip_verify);
72 
73  std::shared_ptr<TProtocol> get_protocol();
74  virtual ~ThriftClientConnection();
75 
76  private:
77  std::string server_host_;
78  int port_;
81  std::string ca_cert_name_;
82  std::string trust_cert_file_;
83  bool using_X509_store_ = false;
84  std::shared_ptr<TSSLSocketFactory> factory_;
85 };
86 
87 #endif // THRIFTCLIENT_H
ThriftConnectionType conn_type_
Definition: ThriftClient.h:79
unsigned connect_timeout
ThriftConnectionType
Definition: ThriftClient.h:31
std::shared_ptr< TTransport > open_http_client_transport(const std::string &server_host, const int port, const std::string &trust_cert_file_, bool use_https, bool skip_verify)
virtual ~ThriftClientConnection()
unsigned send_timeout
std::shared_ptr< TTransport > open_buffered_client_transport(const std::string &server_host, const int port, const std::string &ca_cert_name, const bool with_timeout=false, const bool with_keepalive=true, const unsigned connect_timeout=0, const unsigned recv_timeount=0, const unsigned send_timeout=0)
std::string ca_cert_name_
Definition: ThriftClient.h:81
bool with_keepalive
std::string trust_cert_file_
Definition: ThriftClient.h:82
std::string server_host_
Definition: ThriftClient.h:77
std::shared_ptr< TProtocol > get_protocol()
std::shared_ptr< TSSLSocketFactory > factory_
Definition: ThriftClient.h:84
ThriftClientConnection(const std::string &server_host, const int port, const ThriftConnectionType conn_type, bool skip_host_verify, const std::string &ca_cert_name, const std::string &trust_cert_file)
Definition: ThriftClient.h:35