8#include <userver/clients/dns/resolver_fwd.hpp>
9#include <userver/dynamic_config/source.hpp>
10#include <userver/engine/task/task_processor_fwd.hpp>
11#include <userver/engine/task/task_with_result.hpp>
12#include <userver/error_injection/settings_fwd.hpp>
13#include <userver/testsuite/postgres_control.hpp>
14#include <userver/testsuite/tasks.hpp>
16#include <userver/storages/postgres/cluster_types.hpp>
17#include <userver/storages/postgres/database.hpp>
18#include <userver/storages/postgres/detail/non_transaction.hpp>
19#include <userver/storages/postgres/options.hpp>
20#include <userver/storages/postgres/query.hpp>
21#include <userver/storages/postgres/statistics.hpp>
22#include <userver/storages/postgres/transaction.hpp>
60USERVER_NAMESPACE_BEGIN
71using ClusterImplPtr = std::unique_ptr<ClusterImpl>;
102 Cluster(DsnList dsns, clients::dns::Resolver* resolver,
103 engine::TaskProcessor& bg_task_processor,
105 DefaultCommandControls&& default_cmd_ctls,
108 testsuite::TestsuiteTasks& testsuite_tasks,
109 dynamic_config::Source config_source,
int shard_number);
136 OptionalCommandControl = {});
171 template <
typename... Args>
173 const Args&... args);
182 template <
typename... Args>
184 const Query& query,
const Args&... args);
194 OptionalCommandControl statement_cmd_ctl,
204 void SetHandlersCommandControl(
205 CommandControlByHandlerMap handlers_command_control);
207 void SetQueriesCommandControl(
208 CommandControlByQueryMap queries_command_control);
222 void SetStatementMetricsSettings(
const StatementMetricsSettings& settings);
225 detail::NonTransaction Start(ClusterHostTypeFlags, OptionalCommandControl);
227 OptionalCommandControl GetQueryCmdCtl(
const std::string& query_name)
const;
228 OptionalCommandControl GetHandlersCmdCtl(
229 OptionalCommandControl cmd_ctl)
const;
231 detail::ClusterImplPtr pimpl_;
234template <
typename... Args>
236 const Args&... args) {
237 return Execute(flags, OptionalCommandControl{}, query, args...);
240template <
typename... Args>
242 OptionalCommandControl statement_cmd_ctl,
243 const Query& query,
const Args&... args) {
244 if (!statement_cmd_ctl && query.GetName()) {
245 statement_cmd_ctl = GetQueryCmdCtl(query.GetName()->GetUnderlying());
247 statement_cmd_ctl = GetHandlersCmdCtl(statement_cmd_ctl);
248 auto ntrx = Start(flags, statement_cmd_ctl);
249 return ntrx.Execute(statement_cmd_ctl, query, args...);