OmniSciDB  04ee39c94c
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& ca_cert_name);
51 
52  mapd::shared_ptr<TTransport> open_buffered_client_transport(
53  const std::string& server_host,
54  const int port,
55  const std::string& ca_cert_name,
56  const bool with_timeout = false,
57  const unsigned connect_timeout = 0,
58  const unsigned recv_timeount = 0,
59  const unsigned send_timeout = 0);
60 
61  mapd::shared_ptr<TTransport> open_http_client_transport(
62  const std::string& server_host,
63  const int port,
64  const std::string& trust_cert_file_,
65  bool use_https,
66  bool skip_verify);
67 
68  mapd::shared_ptr<TProtocol> get_protocol();
69 
70  private:
71  std::string server_host_;
72  int port_;
75  std::string ca_cert_name_;
76  std::string trust_cert_file_;
77 
78  mapd::shared_ptr<TSSLSocketFactory> factory_;
79 };
80 
81 #endif // THRIFTCLIENT_H
ThriftConnectionType conn_type_
Definition: ThriftClient.h:73
ThriftConnectionType
Definition: ThriftClient.h:32
unsigned connect_timeout
Definition: MapDServer.cpp:56
mapd::shared_ptr< TSSLSocketFactory > factory_
Definition: ThriftClient.h:78
std::string ca_cert_name_
Definition: ThriftClient.h:75
std::string trust_cert_file_
Definition: ThriftClient.h:76
std::string server_host_
Definition: ThriftClient.h:71
unsigned send_timeout
Definition: MapDServer.cpp:58
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