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"
52 explicit Handle(std::string_view contactPoints);
100 connect(std::string_view keyspace)
const;
138 reconnect(std::string_view keyspace)
const;
148 template <
typename... Args>
152 auto const statement =
StatementType{query, std::forward<Args>(args)...};
153 return cass_session_execute(session_, statement);
166 template <
typename... Args>
168 execute(std::string_view query, Args&&... args)
const
170 return asyncExecute<Args...>(query, std::forward<Args>(args)...).get();
183 [[nodiscard]] std::vector<FutureType>
195 executeEach(std::vector<StatementType>
const& statements)
const;
205 template <
typename... Args>
209 auto const bound = statement.
bind<Args...>(std::forward<Args>(args)...);
210 return cass_session_execute(session_, bound);
223 template <
typename... Args>
227 return asyncExecute<Args...>(statement, std::forward<Args>(args)...).get();
267 asyncExecute(std::vector<StatementType>
const& statements)
const;
278 execute(std::vector<StatementType>
const& statements)
const;
290 std::vector<StatementType>
const& statements,
302 prepare(std::string_view query)
const;
316template <
typename... Types>
317[[nodiscard]] impl::ResultExtractor<Types...>
PreparedStatement PreparedStatementType
A prepared statement.
Definition Handle.hpp:37
FutureWithCallback FutureWithCallbackType
Future that invokes a callback.
Definition Handle.hpp:34
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
ResultOrError ResultOrErrorType
A query result or an error.
Definition Handle.hpp:32
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:225
Statement StatementType
A simple or bound statement.
Definition Handle.hpp:36
FutureType asyncExecute(std::string_view query, Args &&... args) const
Execute a simple query with optional args asynchronously.
Definition Handle.hpp:150
ResultOrErrorType execute(std::string_view query, Args &&... args) const
Synchronous version of the above.
Definition Handle.hpp:168
Result ResultType
A query result.
Definition Handle.hpp:38
Future FutureType
Future of an asynchronous query.
Definition Handle.hpp:35
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
MaybeError MaybeErrorType
Success or an error.
Definition Handle.hpp:33
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:207
Definition Cluster.hpp:157
Statement bind(Args &&... args) const
Bind the given arguments and produce a ready to execute Statement.
Definition Statement.hpp:174
This namespace implements a wrapper for the Cassandra C++ driver.
Definition CassandraBackendFamily.hpp:50
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:318
std::expected< void, CassandraError > MaybeError
Success or a database error.
Definition Types.hpp:65
impl::Future Future
Future of an asynchronous query.
Definition Types.hpp:24
impl::Statement Statement
A simple or bound statement.
Definition Types.hpp:27
impl::PreparedStatement PreparedStatement
A prepared statement.
Definition Types.hpp:28
std::expected< Result, CassandraError > ResultOrError
A query result or an error.
Definition Types.hpp:66
impl::Settings Settings
All Cassandra backend settings.
Definition Types.hpp:23
impl::Result Result
Result of a query.
Definition Types.hpp:26
impl::FutureWithCallback FutureWithCallback
Future that invokes a callback.
Definition Types.hpp:25
static Settings defaultSettings()
Returns the default settings.
Definition Cluster.hpp:151