#include </data/code/userver/mysql/include/userver/storages/mysql/cluster.hpp>
Client interface for a cluster of MySQL servers. Usually retrieved from components::MySQL.
Definition at line 40 of file cluster.hpp.
Public Member Functions | |
Cluster (clients::dns::Resolver &resolver, const settings::MysqlSettings &settings, const components::ComponentConfig &config) | |
Cluster constructor. | |
~Cluster () | |
Cluster destructor. | |
template<typename... Args> | |
StatementResultSet | Execute (ClusterHostType host_type, const Query &query, const Args &... args) const |
Executes a statement on a host of host_type with default deadline. Fills placeholders of the statement with args..., Args are expected to be of supported types. See MySQL supported types for better understanding of Args requirements. | |
template<typename... Args> | |
StatementResultSet | Execute (OptionalCommandControl command_control, ClusterHostType host_type, const Query &query, const Args &... args) const |
Executes a statement on a host of host_type with provided CommandControl. Fills placeholders of the statement with args..., Args are expected to be of supported types. See MySQL supported types for better understanding of Args requirements. | |
template<typename T > | |
StatementResultSet | ExecuteDecompose (ClusterHostType host_type, const Query &query, const T &row) const |
Executes a statement on a host of host_type with default deadline. | |
template<typename T > | |
StatementResultSet | ExecuteDecompose (OptionalCommandControl command_control, ClusterHostType host_type, const Query &query, const T &row) const |
Executes a statement on a host of host_type with provided CommandControl. | |
template<typename Container > | |
StatementResultSet | ExecuteBulk (ClusterHostType host_type, const Query &query, const Container ¶ms) const |
Executes a statement on a host of host_type with default deadline. Fills placeholders of the statements with Container::value_type in a bulk-manner. Container is expected to be a std::Container, Container::value_type is expected to be an aggregate of supported types. See MySQL supported types for better understanding of Container::value_type requirements. | |
template<typename Container > | |
StatementResultSet | ExecuteBulk (OptionalCommandControl command_control, ClusterHostType host_type, const Query &query, const Container ¶ms) const |
Executes a statement on a host of host_type with provided CommandControl. Fills placeholders of the statements with Container::value_type in a bulk-manner. Container is expected to be a std::Container, Container::value_type is expected to be an aggregate of supported types. See MySQL supported types for better understanding of Container::value_type requirements. | |
template<typename MapTo , typename Container > | |
StatementResultSet | ExecuteBulkMapped (ClusterHostType host_type, const Query &query, const Container ¶ms) const |
Executes a statement on a host of host_type with default deadline, on the flight remapping from Container::value_type to MapTo . Container is expected to be a std::Container of whatever type pleases you, MapTo is expected to be an aggregate of supported types. See MySQL supported types for better understanding of MapTo requirements. You are expected to provide a converter function MapTo Convert(const Container::value_type&, storages::mysql::convert::To<MapTo>) in namespace of MapTo or storages::mysql::convert. | |
template<typename MapTo , typename Container > | |
StatementResultSet | ExecuteBulkMapped (OptionalCommandControl command_control, ClusterHostType host_type, const Query &query, const Container ¶ms) const |
Executes a statement on a host of host_type with provided CommandControl, on the flight remapping from Container::value_type to MapTo . Container is expected to be a std::Container of whatever type pleases you, MapTo is expected to be an aggregate of supported types. See MySQL supported types for better understanding of MapTo requirements. You are expected to provide a converter function MapTo Convert(const Container::value_type&, storages::mysql::convert::To<MapTo>) in namespace of MapTo or storages::mysql::convert. | |
Transaction | Begin (ClusterHostType host_type) const |
Begin a transaction with default deadline. | |
Transaction | Begin (OptionalCommandControl command_control, ClusterHostType host_type) const |
Being a transaction with specified CommandControl. | |
CommandResultSet | ExecuteCommand (ClusterHostType host_type, const Query &command) const |
Executes a command on host of type host_type over plan-text protocol, with default deadline. | |
CommandResultSet | ExecuteCommand (OptionalCommandControl command_control, ClusterHostType host_type, const Query &command) const |
Executes a command on host of type host_type over plan-text protocol, with provided CommandControl. | |
template<typename T , typename... Args> | |
CursorResultSet< T > | GetCursor (ClusterHostType host_type, std::size_t batch_size, const Query &query, const Args &... args) const |
Executes a statement with default deadline on a host of host_type, filling statements placeholders with args... , and returns a read-only cursor which fetches batch_count rows in each next fetch request. See MySQL supported types for better understanding of Args requirements. | |
template<typename T , typename... Args> | |
CursorResultSet< T > | GetCursor (OptionalCommandControl command_control, ClusterHostType host_type, std::size_t batch_size, const Query &query, const Args &... args) const |
Executes a statement with provided CommandControl on a host of host_type, filling statements placeholders with args... , and returns a read-only cursor which fetches batch_count rows in each next fetch request. See MySQL supported types for better understanding of Args requirements. | |
void | WriteStatistics (utils::statistics::Writer &writer) const |
Write cluster statistics. | |
Transaction storages::mysql::Cluster::Begin | ( | ClusterHostType | host_type | ) | const |
Begin a transaction with default deadline.
host_type | Host type on which to execute transaction. |
Transaction storages::mysql::Cluster::Begin | ( | OptionalCommandControl | command_control, |
ClusterHostType | host_type ) const |
Being a transaction with specified CommandControl.
host_type | Host type on which to execute transaction. |
StatementResultSet storages::mysql::Cluster::Execute | ( | ClusterHostType | host_type, |
const Query & | query, | ||
const Args &... | args ) const |
Executes a statement on a host of host_type with default deadline. Fills placeholders of the statement with args..., Args
are expected to be of supported types. See MySQL supported types for better understanding of Args
requirements.
UINVARIANTs on params count mismatch doesn't validate types.
Definition at line 290 of file cluster.hpp.
StatementResultSet storages::mysql::Cluster::Execute | ( | OptionalCommandControl | command_control, |
ClusterHostType | host_type, | ||
const Query & | query, | ||
const Args &... | args ) const |
Executes a statement on a host of host_type with provided CommandControl. Fills placeholders of the statement with args..., Args
are expected to be of supported types. See MySQL supported types for better understanding of Args
requirements.
UINVARIANTs on params count mismatch doesn't validate types.
Definition at line 295 of file cluster.hpp.
StatementResultSet storages::mysql::Cluster::ExecuteBulk | ( | ClusterHostType | host_type, |
const Query & | query, | ||
const Container & | params ) const |
Executes a statement on a host of host_type with default deadline. Fills placeholders of the statements with Container::value_type in a bulk-manner. Container is expected to be a std::Container, Container::value_type is expected to be an aggregate of supported types. See MySQL supported types for better understanding of Container::value_type
requirements.
UINVARIANTs on params count mismatch, doesn't validate types. UINVARIANTs on empty params container.
Definition at line 324 of file cluster.hpp.
StatementResultSet storages::mysql::Cluster::ExecuteBulk | ( | OptionalCommandControl | command_control, |
ClusterHostType | host_type, | ||
const Query & | query, | ||
const Container & | params ) const |
Executes a statement on a host of host_type with provided CommandControl. Fills placeholders of the statements with Container::value_type in a bulk-manner. Container is expected to be a std::Container, Container::value_type is expected to be an aggregate of supported types. See MySQL supported types for better understanding of Container::value_type
requirements.
UINVARIANTs on params count mismatch, doesn't validate types. UINVARIANTs on empty params container.
Definition at line 329 of file cluster.hpp.
StatementResultSet storages::mysql::Cluster::ExecuteBulkMapped | ( | ClusterHostType | host_type, |
const Query & | query, | ||
const Container & | params ) const |
Executes a statement on a host of host_type with default deadline, on the flight remapping from Container::value_type
to MapTo
. Container
is expected to be a std::Container of whatever type pleases you, MapTo
is expected to be an aggregate of supported types. See MySQL supported types for better understanding of MapTo
requirements. You are expected to provide a converter function MapTo Convert(const Container::value_type&, storages::mysql::convert::To<MapTo>)
in namespace of MapTo
or storages::mysql::convert.
UINVARIANTs on params count mismatch, doesn't validate types. UINVARIANTs on empty params container.
Definition at line 343 of file cluster.hpp.
StatementResultSet storages::mysql::Cluster::ExecuteBulkMapped | ( | OptionalCommandControl | command_control, |
ClusterHostType | host_type, | ||
const Query & | query, | ||
const Container & | params ) const |
Executes a statement on a host of host_type with provided CommandControl, on the flight remapping from Container::value_type
to MapTo
. Container
is expected to be a std::Container of whatever type pleases you, MapTo
is expected to be an aggregate of supported types. See MySQL supported types for better understanding of MapTo
requirements. You are expected to provide a converter function MapTo Convert(const Container::value_type&, storages::mysql::convert::To<MapTo>)
in namespace of MapTo
or storages::mysql::convert.
UINVARIANTs on params count mismatch, doesn't validate types. UINVARIANTs on empty params container.
Definition at line 349 of file cluster.hpp.
CommandResultSet storages::mysql::Cluster::ExecuteCommand | ( | ClusterHostType | host_type, |
const Query & | command ) const |
Executes a command on host of type host_type over plan-text protocol, with default deadline.
This method is intended to be used for statements that cannot be prepared or as an escape hatch from typed parsing if you really need to, but such use is neither recommended nor optimized for.
CommandResultSet storages::mysql::Cluster::ExecuteCommand | ( | OptionalCommandControl | command_control, |
ClusterHostType | host_type, | ||
const Query & | command ) const |
Executes a command on host of type host_type over plan-text protocol, with provided CommandControl.
This method is intended to be used for statements that cannot be prepared or as an escape hatch from typed parsing if you really need to, but such use is neither recommended nor optimized for.
StatementResultSet storages::mysql::Cluster::ExecuteDecompose | ( | ClusterHostType | host_type, |
const Query & | query, | ||
const T & | row ) const |
Executes a statement on a host of host_type with default deadline.
Basically an alias for Execute(host_type, query, AsArgs<T>(row)), where AsArgs is an imaginary function which passes fields of T as variadic params. Handy for one-liner inserts. See MySQL supported types for better understanding of T
requirements.
UINVARIANTs on params count mismatch, doesn't validate types.
Definition at line 307 of file cluster.hpp.
StatementResultSet storages::mysql::Cluster::ExecuteDecompose | ( | OptionalCommandControl | command_control, |
ClusterHostType | host_type, | ||
const Query & | query, | ||
const T & | row ) const |
Executes a statement on a host of host_type with provided CommandControl.
Basically an alias for Execute(command_control, host_type, query,
AsArgs<T>(row)), where AsArgs is an imaginary function which passes fields of T as variadic params. Handy for one-liner inserts. See MySQL supported types for better understanding of T
requirements.
UINVARIANTs on params count mismatch, doesn't validate types.
Definition at line 312 of file cluster.hpp.
CursorResultSet< T > storages::mysql::Cluster::GetCursor | ( | ClusterHostType | host_type, |
std::size_t | batch_size, | ||
const Query & | query, | ||
const Args &... | args ) const |
Executes a statement with default deadline on a host of host_type, filling statements placeholders with args...
, and returns a read-only cursor which fetches batch_count
rows in each next fetch request. See MySQL supported types for better understanding of Args
requirements.
UINVARIANTs on params count mismatch, doesn't validate types.
Definition at line 364 of file cluster.hpp.
CursorResultSet< T > storages::mysql::Cluster::GetCursor | ( | OptionalCommandControl | command_control, |
ClusterHostType | host_type, | ||
std::size_t | batch_size, | ||
const Query & | query, | ||
const Args &... | args ) const |
Executes a statement with provided CommandControl on a host of host_type, filling statements placeholders with args...
, and returns a read-only cursor which fetches batch_count
rows in each next fetch request. See MySQL supported types for better understanding of Args
requirements.
UINVARIANTs on params count mismatch, doesn't validate types.
Definition at line 369 of file cluster.hpp.