OmniSciDB  a987f07e93
 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 2022 HEAVY.AI, 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/TProtocol.h>
20 #include <thrift/transport/TSSLSocket.h>
21 #include <string>
22 // TProtocol.h > winsock2.h > windows.h
24 
25 using namespace ::apache::thrift::transport;
26 using namespace ::apache::thrift::protocol;
27 using namespace ::apache::thrift::transport;
28 
30 
32  public:
33  ThriftClientConnection(const std::string& server_host,
34  const int port,
35  const ThriftConnectionType conn_type,
36  bool skip_host_verify,
37  const std::string& ca_cert_name,
38  const std::string& trust_cert_file)
39  : server_host_(server_host)
40  , port_(port)
41  , conn_type_(conn_type)
42  , skip_host_verify_(skip_host_verify)
43  , ca_cert_name_(ca_cert_name)
44  , trust_cert_file_(trust_cert_file){};
45 
46  ThriftClientConnection(const std::string& server_host,
47  const int port,
48  const ThriftConnectionType conn_type,
49  bool skip_host_verify,
50  std::shared_ptr<TSSLSocketFactory> factory);
51 
53 
54  std::shared_ptr<TTransport> open_buffered_client_transport(
55  const std::string& server_host,
56  const int port,
57  const std::string& ca_cert_name,
58  const bool with_timeout = false,
59  const bool with_keepalive = true,
60  const unsigned connect_timeout = 0,
61  const unsigned recv_timeount = 0,
62  const unsigned send_timeout = 0);
63 
64  std::shared_ptr<TTransport> open_http_client_transport(
65  const std::string& server_host,
66  const int port,
67  const std::string& trust_cert_file_,
68  bool use_https,
69  bool skip_verify);
70 
71  std::shared_ptr<TProtocol> get_protocol();
72  virtual ~ThriftClientConnection();
73 
74  private:
75  std::string server_host_;
76  int port_;
79  std::string ca_cert_name_;
80  std::string trust_cert_file_;
81  bool using_X509_store_ = false;
82  std::shared_ptr<TSSLSocketFactory> factory_;
83 };
84 
85 #endif // THRIFTCLIENT_H
ThriftConnectionType conn_type_
Definition: ThriftClient.h:77
unsigned connect_timeout
ThriftConnectionType
Definition: ThriftClient.h:29
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:79
bool with_keepalive
std::string trust_cert_file_
Definition: ThriftClient.h:80
std::string server_host_
Definition: ThriftClient.h:75
std::shared_ptr< TProtocol > get_protocol()
std::shared_ptr< TSSLSocketFactory > factory_
Definition: ThriftClient.h:82
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:33