OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 #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 unsigned connect_timeout = 0,
63  const unsigned recv_timeount = 0,
64  const unsigned send_timeout = 0);
65 
66  mapd::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  mapd::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  mapd::shared_ptr<TSSLSocketFactory> factory_;
85 };
86 
87 #endif // THRIFTCLIENT_H
ThriftConnectionType conn_type_
Definition: ThriftClient.h:79
ThriftConnectionType
Definition: ThriftClient.h:32
mapd::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 connect_timeout
Definition: MapDServer.cpp:70
mapd::shared_ptr< TSSLSocketFactory > factory_
Definition: ThriftClient.h:84
mapd::shared_ptr< TProtocol > get_protocol()
mapd::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 unsigned connect_timeout=0, const unsigned recv_timeount=0, const unsigned send_timeout=0)
std::string ca_cert_name_
Definition: ThriftClient.h:81
std::string trust_cert_file_
Definition: ThriftClient.h:82
std::string server_host_
Definition: ThriftClient.h:77
unsigned send_timeout
Definition: MapDServer.cpp:72
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