22#include "data/cassandra/Error.hpp"
23#include "data/cassandra/Types.hpp"
24#include "data/cassandra/impl/Batch.hpp"
25#include "data/cassandra/impl/Cluster.hpp"
26#include "data/cassandra/impl/Future.hpp"
27#include "data/cassandra/impl/ManagedObject.hpp"
28#include "data/cassandra/impl/Result.hpp"
29#include "data/cassandra/impl/Session.hpp"
30#include "data/cassandra/impl/Statement.hpp"
51 using ResultOrErrorType = ResultOrError;
52 using MaybeErrorType = MaybeError;
71 explicit Handle(std::string_view contactPoints);
98 [[nodiscard]] MaybeErrorType
118 [[nodiscard]] MaybeErrorType
119 connect(std::string_view keyspace)
const;
136 [[maybe_unused]] MaybeErrorType
156 [[nodiscard]] MaybeErrorType
157 reconnect(std::string_view keyspace)
const;
166 template <
typename... Args>
170 auto statement =
StatementType{query, std::forward<Args>(args)...};
171 return cass_session_execute(session_, statement);
183 template <
typename... Args>
184 [[maybe_unused]] ResultOrErrorType
185 execute(std::string_view query, Args&&... args)
const
187 return asyncExecute<Args...>(query, std::forward<Args>(args)...).get();
200 [[nodiscard]] std::vector<FutureType>
211 [[maybe_unused]] MaybeErrorType
212 executeEach(std::vector<StatementType>
const& statements)
const;
221 template <
typename... Args>
222 [[nodiscard]] FutureType
225 auto bound = statement.
bind<Args...>(std::forward<Args>(args)...);
226 return cass_session_execute(session_, bound);
238 template <
typename... Args>
239 [[maybe_unused]] ResultOrErrorType
242 return asyncExecute<Args...>(statement, std::forward<Args>(args)...).get();
251 [[nodiscard]] FutureType
261 [[nodiscard]] FutureWithCallbackType
262 asyncExecute(StatementType
const& statement, std::function<
void(ResultOrErrorType)>&& cb)
const;
272 [[maybe_unused]] ResultOrErrorType
273 execute(StatementType
const& statement)
const;
281 [[nodiscard]] FutureType
282 asyncExecute(std::vector<StatementType>
const& statements)
const;
292 [[maybe_unused]] MaybeErrorType
293 execute(std::vector<StatementType>
const& statements)
const;
302 [[nodiscard]] FutureWithCallbackType
303 asyncExecute(std::vector<StatementType>
const& statements, std::function<
void(ResultOrErrorType)>&& cb)
const;
312 [[nodiscard]] PreparedStatementType
313 prepare(std::string_view query)
const;
327template <
typename... Types>
328[[nodiscard]] impl::ResultExtractor<Types...>
Represents a handle to the cassandra database cluster.
Definition Handle.hpp:46
MaybeErrorType connect() const
Synchonous version of the above.
Definition Handle.cpp:55
MaybeErrorType reconnect(std::string_view keyspace) const
Synchonous version of the above.
Definition Handle.cpp:93
MaybeErrorType disconnect() const
Synchonous version of the above.
Definition Handle.cpp:79
FutureType asyncReconnect(std::string_view keyspace) const
Reconnect to the the specified keyspace asynchronously.
Definition Handle.cpp:85
Handle(Handle &&)=default
Move is supported.
FutureType asyncDisconnect() const
Disconnect from the cluster asynchronously.
Definition Handle.cpp:73
std::vector< FutureType > asyncExecuteEach(std::vector< StatementType > const &statements) const
Execute each of the statements asynchronously.
Definition Handle.cpp:99
MaybeErrorType executeEach(std::vector< StatementType > const &statements) const
Synchonous version of the above.
Definition Handle.cpp:109
ResultOrErrorType execute(PreparedStatementType const &statement, Args &&... args) const
Synchonous version of the above.
Definition Handle.hpp:240
FutureType asyncExecute(std::string_view query, Args &&... args) const
Execute a simple query with optional args asynchronously.
Definition Handle.hpp:168
ResultOrErrorType execute(std::string_view query, Args &&... args) const
Synchonous version of the above.
Definition Handle.hpp:185
FutureType asyncConnect() const
Connect to the cluster asynchronously.
Definition Handle.cpp:49
~Handle()
Disconnects gracefully if possible.
Definition Handle.cpp:43
Handle(Settings clusterSettings=Settings::defaultSettings())
Construct a new handle from a Settings object.
Definition Handle.cpp:35
PreparedStatementType prepare(std::string_view query) const
Prepare a statement.
Definition Handle.cpp:156
FutureType asyncExecute(PreparedStatementType const &statement, Args &&... args) const
Execute a prepared statement with optional args asynchronously.
Definition Handle.hpp:223
Definition Cluster.hpp:124
Represents a prepared statement on the DB side.
Definition Statement.hpp:155
Statement bind(Args &&... args) const
Bind the given arguments and produce a ready to execute Statement.
Definition Statement.hpp:171
Definition Session.hpp:28
Definition Statement.hpp:45
This namespace implements a wrapper for the Cassandra C++ driver.
Definition Concepts.hpp:37
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:329
Definition Result.hpp:110
Bundles all cassandra settings in one place.
Definition Cluster.hpp:43
static Settings defaultSettings()
Returns the default settings.
Definition Cluster.hpp:118