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