Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType > Class Template Reference

Implements async and sync querying against the cassandra DB with support for throttling. More...

#include <ExecutionStrategy.hpp>

Public Types

using ResultOrErrorType = HandleType::ResultOrErrorType
using StatementType = HandleType::StatementType
using PreparedStatementType = HandleType::PreparedStatementType
using FutureType = HandleType::FutureType
using FutureWithCallbackType = HandleType::FutureWithCallbackType
using ResultType = HandleType::ResultType
using CompletionTokenType = boost::asio::yield_context

Public Member Functions

 DefaultExecutionStrategy (Settings const &settings, HandleType const &handle, BackendCountersType::PtrType counters=BackendCountersType::make())
void sync ()
 Wait for all async writes to finish before unblocking.
bool isTooBusy () const
ResultOrErrorType writeSync (StatementType const &statement)
 Blocking query execution used for writing data.
template<typename... Args>
ResultOrErrorType writeSync (PreparedStatementType const &preparedStatement, Args &&... args)
 Blocking query execution used for writing data.
template<typename... Args>
void write (PreparedStatementType const &preparedStatement, Args &&... args)
 Non-blocking query execution used for writing data.
void write (StatementType &&statement)
 Non-blocking query execution used for writing data.
void write (std::vector< StatementType > &&statements)
 Non-blocking batched query execution used for writing data.
void writeEach (std::vector< StatementType > &&statements)
 Non-blocking query execution used for writing data. Contrast with write, this method does not execute the statements in a batch.
template<typename... Args>
ResultOrErrorType read (CompletionTokenType token, PreparedStatementType const &preparedStatement, Args &&... args)
 Coroutine-based query execution used for reading data.
ResultOrErrorType read (CompletionTokenType token, std::vector< StatementType > const &statements)
 Coroutine-based query execution used for reading data.
ResultOrErrorType read (CompletionTokenType token, StatementType const &statement)
 Coroutine-based query execution used for reading data.
std::vector< ResultType > readEach (CompletionTokenType token, std::vector< StatementType > const &statements)
 Coroutine-based query execution used for reading data.
boost::json::object stats () const
 Get statistics about the backend.

Detailed Description

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
class data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >

Implements async and sync querying against the cassandra DB with support for throttling.

Note: A lot of the code that uses yield is repeated below. This is ok for now because we are hopefully going to be getting rid of it entirely later on.

Constructor & Destructor Documentation

◆ DefaultExecutionStrategy()

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::DefaultExecutionStrategy ( Settings const & settings,
HandleType const & handle,
BackendCountersType::PtrType counters = BackendCountersType::make() )
inline
Parameters
settingsThe settings to use
handleA handle to the cassandra database

Member Function Documentation

◆ isTooBusy()

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
bool data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::isTooBusy ( ) const
inlinenodiscard
Returns
true if outstanding read requests allowance is exhausted; false otherwise

◆ read() [1/3]

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
template<typename... Args>
ResultOrErrorType data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::read ( CompletionTokenType token,
PreparedStatementType const & preparedStatement,
Args &&... args )
inline

Coroutine-based query execution used for reading data.

Retries forever until successful or throws an exception on timeout.

Parameters
tokenCompletion token (yield_context)
preparedStatementStatement to prepare and execute
argsArgs to bind to the prepared statement
Exceptions
DatabaseErroron a database error
Returns
ResultType or error wrapped in Expected

◆ read() [2/3]

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
ResultOrErrorType data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::read ( CompletionTokenType token,
StatementType const & statement )
inline

Coroutine-based query execution used for reading data.

Retries forever until successful or throws an exception on timeout.

Parameters
tokenCompletion token (yield_context)
statementStatement to execute
Exceptions
DatabaseErroron a database error
Returns
ResultType or error wrapped in Expected

◆ read() [3/3]

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
ResultOrErrorType data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::read ( CompletionTokenType token,
std::vector< StatementType > const & statements )
inline

Coroutine-based query execution used for reading data.

Retries forever until successful or throws an exception on timeout.

Parameters
tokenCompletion token (yield_context)
statementsStatements to execute in a batch
Exceptions
DatabaseErroron a database error
Returns
ResultType or error wrapped in Expected

◆ readEach()

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
std::vector< ResultType > data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::readEach ( CompletionTokenType token,
std::vector< StatementType > const & statements )
inline

Coroutine-based query execution used for reading data.

Attempts to execute each statement. On any error the whole vector will be discarded and exception will be thrown.

Parameters
tokenCompletion token (yield_context)
statementsStatements to execute
Exceptions
DatabaseErroron a database error
Returns
Vector of results

◆ write() [1/3]

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
template<typename... Args>
void data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::write ( PreparedStatementType const & preparedStatement,
Args &&... args )
inline

Non-blocking query execution used for writing data.

Retries forever with retry policy specified by AsyncExecutor

Parameters
preparedStatementStatement to prepare and execute
argsArgs to bind to the prepared statement
Exceptions
DatabaseErroron a database error

◆ write() [2/3]

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
void data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::write ( StatementType && statement)
inline

Non-blocking query execution used for writing data.

Retries forever with retry policy specified by AsyncExecutor

Parameters
statementStatement to execute
Exceptions
DatabaseErroron a database error

◆ write() [3/3]

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
void data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::write ( std::vector< StatementType > && statements)
inline

Non-blocking batched query execution used for writing data.

Retries forever with retry policy specified by AsyncExecutor.

Parameters
statementsVector of statements to execute as a batch
Exceptions
DatabaseErroron a database error

◆ writeEach()

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
void data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::writeEach ( std::vector< StatementType > && statements)
inline

Non-blocking query execution used for writing data. Contrast with write, this method does not execute the statements in a batch.

Retries forever with retry policy specified by AsyncExecutor.

Parameters
statementsVector of statements to execute
Exceptions
DatabaseErroron a database error

◆ writeSync() [1/2]

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
template<typename... Args>
ResultOrErrorType data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::writeSync ( PreparedStatementType const & preparedStatement,
Args &&... args )
inline

Blocking query execution used for writing data.

Retries forever sleeping for 5 milliseconds between attempts.

◆ writeSync() [2/2]

template<typename HandleType = Handle, SomeBackendCounters BackendCountersType = BackendCounters>
ResultOrErrorType data::cassandra::impl::DefaultExecutionStrategy< HandleType, BackendCountersType >::writeSync ( StatementType const & statement)
inline

Blocking query execution used for writing data.

Retries forever sleeping for 5 milliseconds between attempts.


The documentation for this class was generated from the following file: