#include <userver/storages/clickhouse/cluster.hpp>
Interface for executing queries on a cluster of ClickHouse servers.
Usually retrieved from components::ClickHouse component.
Definition at line 36 of file cluster.hpp.
Classes | |
class | NoAvailablePoolError |
Exception that is thrown if all specified endpoints are unavailable. More... | |
Public Member Functions | |
Cluster (clients::dns::Resolver &resolver, const impl::ClickhouseSettings &settings, const components::ComponentConfig &config) | |
~Cluster () | |
Cluster destructor. | |
Cluster (const Cluster &)=delete | |
template<typename... Args> | |
ExecutionResult | Execute (const Query &query, const Args &... args) const |
Execute a statement at some host of the cluster with args as query parameters. | |
template<typename... Args> | |
ExecutionResult | Execute (OptionalCommandControl, const Query &query, const Args &... args) const |
Execute a statement with specified command control settings at some host of the cluster with args as query parameters. | |
template<typename T > | |
void | Insert (const std::string &table_name, const std::vector< std::string_view > &column_names, const T &data) const |
Insert data at some host of the cluster; T is expected to be a struct of vectors of same length. | |
template<typename T > | |
void | Insert (OptionalCommandControl, const std::string &table_name, const std::vector< std::string_view > &column_names, const T &data) const |
Insert data with specified command control settings at some host of the cluster; T is expected to be a struct of vectors of same length. | |
template<typename Container > | |
void | InsertRows (const std::string &table_name, const std::vector< std::string_view > &column_names, const Container &data) const |
Insert data at some host of the cluster; Container is expected to be an iterable of clickhouse-mapped type. | |
template<typename Container > | |
void | InsertRows (OptionalCommandControl, const std::string &table_name, const std::vector< std::string_view > &column_names, const Container &data) const |
Insert data with specified command control settings at some host of the cluster; Container is expected to be an iterable of clickhouse-mapped type. | |
void | WriteStatistics (::utils::statistics::Writer &writer) const |
Write cluster statistics. | |
storages::clickhouse::Cluster::Cluster | ( | clients::dns::Resolver & | resolver, |
const impl::ClickhouseSettings & | settings, | ||
const components::ComponentConfig & | config ) |
Cluster constructor
resolver | asynchronous DNS resolver |
settings | struct with settings fields: endpoints - list of endpoints (host + port) auth_settings - authentication settings (user, password, database) |
config | components::ClickHouse component config |
ExecutionResult storages::clickhouse::Cluster::Execute | ( | const Query & | query, |
const Args &... | args ) const |
Execute a statement at some host of the cluster with args as query parameters.
Definition at line 187 of file cluster.hpp.
ExecutionResult storages::clickhouse::Cluster::Execute | ( | OptionalCommandControl | optional_cc, |
const Query & | query, | ||
const Args &... | args ) const |
Execute a statement with specified command control settings at some host of the cluster with args as query parameters.
Definition at line 192 of file cluster.hpp.
void storages::clickhouse::Cluster::Insert | ( | const std::string & | table_name, |
const std::vector< std::string_view > & | column_names, | ||
const T & | data ) const |
Insert data at some host of the cluster; T
is expected to be a struct of vectors of same length.
table_name | table to insert into |
column_names | names of columns of the table |
data | data to insert See clickhouse_io for better understanding of T's requirements. |
Definition at line 146 of file cluster.hpp.
void storages::clickhouse::Cluster::Insert | ( | OptionalCommandControl | optional_cc, |
const std::string & | table_name, | ||
const std::vector< std::string_view > & | column_names, | ||
const T & | data ) const |
Insert data with specified command control settings at some host of the cluster; T
is expected to be a struct of vectors of same length.
table_name | table to insert into |
column_names | names of columns of the table |
data | data to insert See clickhouse_io for better understanding of T's requirements. |
Definition at line 152 of file cluster.hpp.
void storages::clickhouse::Cluster::InsertRows | ( | const std::string & | table_name, |
const std::vector< std::string_view > & | column_names, | ||
const Container & | data ) const |
Insert data at some host of the cluster; Container
is expected to be an iterable of clickhouse-mapped type.
table_name | table to insert into |
column_names | names of columns of the table |
data | data to insert See clickhouse_io for better understanding of Container::value_type 's requirements. |
Insert
(it makes 2 copies of data instead of just 1 copy) due to implementation details, so consider using less convenient but more performant analogue if performance is a concern. Definition at line 164 of file cluster.hpp.
void storages::clickhouse::Cluster::InsertRows | ( | OptionalCommandControl | optional_cc, |
const std::string & | table_name, | ||
const std::vector< std::string_view > & | column_names, | ||
const Container & | data ) const |
Insert data with specified command control settings at some host of the cluster; Container
is expected to be an iterable of clickhouse-mapped type.
table_name | table to insert into |
column_names | names of columns of the table |
data | data to insert See clickhouse_io for better understanding of Container::value_type 's requirements. |
Insert
(it makes 2 copies of data instead of just 1 copy) due to implementation details, so consider using less convenient but more performant analogue if performance is a concern. Definition at line 173 of file cluster.hpp.