Kinetic C/C++ Client
 All Classes Functions Variables Pages
kinetic_connection_factory.h
1 /*
2  * kinetic-cpp-client
3  * Copyright (C) 2014 Seagate Technology.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #ifndef KINETIC_CPP_CLIENT_KINETIC_CONNECTION_FACTORY_H_
22 #define KINETIC_CPP_CLIENT_KINETIC_CONNECTION_FACTORY_H_
23 
24 #include "kinetic/connection_options.h"
25 #include "kinetic/hmac_provider.h"
26 #include "kinetic/blocking_kinetic_connection.h"
27 #include "kinetic/nonblocking_kinetic_connection.h"
28 #include "kinetic/threadsafe_nonblocking_connection.h"
29 #include "kinetic/threadsafe_blocking_kinetic_connection.h"
30 #include "kinetic/status.h"
31 #include <memory>
32 
33 namespace kinetic {
34 
35 using std::unique_ptr;
36 
40  public:
41  explicit KineticConnectionFactory(HmacProvider hmac_provider);
42 
55  const ConnectionOptions& options,
56  unique_ptr <NonblockingKineticConnection>& connection);
57 
59  const ConnectionOptions& options,
60  shared_ptr <NonblockingKineticConnection>& connection);
61 
64  const ConnectionOptions& options,
65  unique_ptr <ThreadsafeNonblockingKineticConnection>& connection);
66 
68  const ConnectionOptions& options,
69  shared_ptr <ThreadsafeNonblockingKineticConnection>& connection);
70 
83  const ConnectionOptions& options,
84  unique_ptr <BlockingKineticConnection>& connection,
85  unsigned int network_timeout_seconds);
86 
88  const ConnectionOptions& options,
89  shared_ptr <BlockingKineticConnection>& connection,
90  unsigned int network_timeout_seconds);
91 
94  const ConnectionOptions& options,
95  unique_ptr <ThreadsafeBlockingKineticConnection>& connection,
96  unsigned int network_timeout_seconds);
97 
99  const ConnectionOptions& options,
100  shared_ptr <ThreadsafeBlockingKineticConnection>& connection,
101  unsigned int network_timeout_seconds);
102 
103  private:
104  HmacProvider hmac_provider_;
105  Status doNewConnection(
106  ConnectionOptions const& options,
107  unique_ptr <NonblockingKineticConnection>& connection);
108 };
109 
112 KineticConnectionFactory NewKineticConnectionFactory();
113 
114 } // namespace kinetic
115 
116 #endif // KINETIC_CPP_CLIENT_KINETIC_CONNECTION_FACTORY_H_
Factory class that builds KineticConnection instances. Rather than use the constructor developers sho...
Status NewThreadsafeNonblockingConnection(const ConnectionOptions &options, unique_ptr< ThreadsafeNonblockingKineticConnection > &connection)
Like NewNonblockingConnection, except the connection is safe for use by multiple threads.
Wrapper class that handles computing HMACs. The supplied implementation uses openssl, but users can supply an alternate implementation that uses a different library (e. g. one providing specialized HW accelaration)
Definition: hmac_provider.h:33
Status NewNonblockingConnection(const ConnectionOptions &options, unique_ptr< NonblockingKineticConnection > &connection)
Creates and opens a new nonblocking connection using the given options. If the returned Status indica...
Status NewBlockingConnection(const ConnectionOptions &options, unique_ptr< BlockingKineticConnection > &connection, unsigned int network_timeout_seconds)
Creates and opens a new blocking connection using the given options. If the returned Status indicates...
Status NewThreadsafeBlockingConnection(const ConnectionOptions &options, unique_ptr< ThreadsafeBlockingKineticConnection > &connection, unsigned int network_timeout_seconds)
Like NewBlockingConnection, except the connection is safe for use by multiple threads.
Use this struct to pass all connection options to the KineticConnectionFactory.
Indicates the success/failure of an operation. Frequently when calling a Kinetic client method you'll...
Definition: status.h:41