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/notify.hpp>
20#include <userver/storages/postgres/options.hpp>
21#include <userver/storages/postgres/query.hpp>
22#include <userver/storages/postgres/query_queue.hpp>
23#include <userver/storages/postgres/statistics.hpp>
24#include <userver/storages/postgres/transaction.hpp>
62USERVER_NAMESPACE_BEGIN
73using ClusterImplPtr = std::unique_ptr<ClusterImpl>;
104 Cluster(DsnList dsns, clients::dns::Resolver* resolver,
105 engine::TaskProcessor& bg_task_processor,
107 DefaultCommandControls&& default_cmd_ctls,
110 testsuite::TestsuiteTasks& testsuite_tasks,
111 dynamic_config::Source config_source,
int shard_number);
138 OptionalCommandControl = {});
169 TimeoutDuration acquire_timeout);
182 template <
typename... Args>
184 const Args&... args);
193 template <
typename... Args>
195 const Query& query,
const Args&... args);
205 OptionalCommandControl statement_cmd_ctl,
212 NotifyScope
Listen(std::string_view channel, OptionalCommandControl = {});
220 void SetHandlersCommandControl(
221 CommandControlByHandlerMap handlers_command_control);
223 void SetQueriesCommandControl(
224 CommandControlByQueryMap queries_command_control);
240 void SetStatementMetricsSettings(
const StatementMetricsSettings& settings);
243 detail::NonTransaction Start(ClusterHostTypeFlags, OptionalCommandControl);
245 OptionalCommandControl GetQueryCmdCtl(
const std::string& query_name)
const;
246 OptionalCommandControl GetHandlersCmdCtl(
247 OptionalCommandControl cmd_ctl)
const;
249 detail::ClusterImplPtr pimpl_;
252template <
typename... Args>
254 const Args&... args) {
255 return Execute(flags, OptionalCommandControl{}, query, args...);
258template <
typename... Args>
260 OptionalCommandControl statement_cmd_ctl,
261 const Query& query,
const Args&... args) {
262 if (!statement_cmd_ctl && query.GetName()) {
263 statement_cmd_ctl = GetQueryCmdCtl(query.GetName()->GetUnderlying());
265 statement_cmd_ctl = GetHandlersCmdCtl(statement_cmd_ctl);
266 auto ntrx = Start(flags, statement_cmd_ctl);
267 return ntrx.Execute(statement_cmd_ctl, query, args...);