3#include "data/cassandra/Error.hpp"
4#include "data/cassandra/Types.hpp"
5#include "data/cassandra/impl/Batch.hpp"
6#include "data/cassandra/impl/Cluster.hpp"
7#include "data/cassandra/impl/Future.hpp"
8#include "data/cassandra/impl/ManagedObject.hpp"
9#include "data/cassandra/impl/Result.hpp"
10#include "data/cassandra/impl/Session.hpp"
11#include "data/cassandra/impl/Statement.hpp"
32 using ResultOrErrorType = ResultOrError;
33 using MaybeErrorType = MaybeError;
34 using FutureWithCallbackType = FutureWithCallback;
35 using FutureType = Future;
36 using StatementType = Statement;
37 using PreparedStatementType = PreparedStatement;
38 using ResultType = Result;
52 explicit Handle(std::string_view contactPoints);
69 [[nodiscard]] FutureType
79 [[nodiscard]] MaybeErrorType
88 [[nodiscard]] FutureType
99 [[nodiscard]] MaybeErrorType
100 connect(std::string_view keyspace)
const;
107 [[nodiscard]] FutureType
117 [[maybe_unused]] MaybeErrorType
126 [[nodiscard]] FutureType
137 [[nodiscard]] MaybeErrorType
138 reconnect(std::string_view keyspace)
const;
147 template <
typename... Args>
148 [[nodiscard]] FutureType
151 auto statement = StatementType{query, std::forward<Args>(args)...};
152 return cass_session_execute(session_, statement);
164 template <
typename... Args>
165 [[maybe_unused]] ResultOrErrorType
166 execute(std::string_view query, Args&&... args)
const
168 return asyncExecute<Args...>(query, std::forward<Args>(args)...).get();
181 [[nodiscard]] std::vector<FutureType>
192 [[maybe_unused]] MaybeErrorType
193 executeEach(std::vector<StatementType>
const& statements)
const;
202 template <
typename... Args>
203 [[nodiscard]] FutureType
204 asyncExecute(PreparedStatementType
const& statement, Args&&... args)
const
206 auto bound = statement.
bind<Args...>(std::forward<Args>(args)...);
207 return cass_session_execute(session_, bound);
219 template <
typename... Args>
220 [[maybe_unused]] ResultOrErrorType
221 execute(PreparedStatementType
const& statement, Args&&... args)
const
223 return asyncExecute<Args...>(statement, std::forward<Args>(args)...).get();
232 [[nodiscard]] FutureType
242 [[nodiscard]] FutureWithCallbackType
243 asyncExecute(StatementType
const& statement, std::function<
void(ResultOrErrorType)>&& cb)
const;
253 [[maybe_unused]] ResultOrErrorType
254 execute(StatementType
const& statement)
const;
262 [[nodiscard]] FutureType
263 asyncExecute(std::vector<StatementType>
const& statements)
const;
273 [[maybe_unused]] MaybeErrorType
274 execute(std::vector<StatementType>
const& statements)
const;
284 [[nodiscard]] FutureWithCallbackType
286 std::vector<StatementType>
const& statements,
287 std::function<
void(ResultOrErrorType)>&& cb
297 [[nodiscard]] PreparedStatementType
298 prepare(std::string_view query)
const;
312template <
typename... Types>
313[[nodiscard]] impl::ResultExtractor<Types...>
MaybeErrorType connect() const
Synchronous version of the above.
Definition Handle.cpp:37
MaybeErrorType reconnect(std::string_view keyspace) const
Synchronous version of the above.
Definition Handle.cpp:78
MaybeErrorType disconnect() const
Synchronous version of the above.
Definition Handle.cpp:61
FutureType asyncReconnect(std::string_view keyspace) const
Reconnect to the specified keyspace asynchronously.
Definition Handle.cpp:67
Handle(Handle &&)=default
Move is supported.
FutureType asyncDisconnect() const
Disconnect from the cluster asynchronously.
Definition Handle.cpp:55
std::vector< FutureType > asyncExecuteEach(std::vector< StatementType > const &statements) const
Execute each of the statements asynchronously.
Definition Handle.cpp:84
MaybeErrorType executeEach(std::vector< StatementType > const &statements) const
Synchronous version of the above.
Definition Handle.cpp:94
ResultOrErrorType execute(PreparedStatementType const &statement, Args &&... args) const
Synchronous version of the above.
Definition Handle.hpp:221
FutureType asyncExecute(std::string_view query, Args &&... args) const
Execute a simple query with optional args asynchronously.
Definition Handle.hpp:149
ResultOrErrorType execute(std::string_view query, Args &&... args) const
Synchronous version of the above.
Definition Handle.hpp:166
FutureType asyncConnect() const
Connect to the cluster asynchronously.
Definition Handle.cpp:31
~Handle()
Disconnects gracefully if possible.
Definition Handle.cpp:25
Handle(Settings clusterSettings=Settings::defaultSettings())
Construct a new handle from a Settings object.
Definition Handle.cpp:16
PreparedStatementType prepare(std::string_view query) const
Prepare a statement.
Definition Handle.cpp:149
FutureType asyncExecute(PreparedStatementType const &statement, Args &&... args) const
Execute a prepared statement with optional args asynchronously.
Definition Handle.hpp:204
Definition Cluster.hpp:129
Statement bind(Args &&... args) const
Bind the given arguments and produce a ready to execute Statement.
Definition Statement.hpp:175
This namespace implements a wrapper for the Cassandra C++ driver.
Definition CassandraBackendFamily.hpp:47
impl::ResultExtractor< Types... > extract(Handle::ResultType const &result)
Extracts the results into series of std::tuple<Types...> by creating a simple wrapper with an STL inp...
Definition Handle.hpp:314
static Settings defaultSettings()
Returns the default settings.
Definition Cluster.hpp:123