7#include <userver/storages/postgres/options.hpp>
8#include <userver/storages/postgres/query.hpp>
9#include <userver/storages/postgres/result_set.hpp>
11#include <userver/storages/postgres/detail/connection_ptr.hpp>
12#include <userver/storages/postgres/detail/query_parameters.hpp>
14#include <userver/utils/any_movable.hpp>
15#include <userver/utils/fast_pimpl.hpp>
17USERVER_NAMESPACE_BEGIN
41class QueryQueue
final {
43 QueryQueue(
CommandControl default_cc, detail::ConnectionPtr&& conn);
45 QueryQueue(QueryQueue&&)
noexcept;
46 QueryQueue& operator=(QueryQueue&&)
noexcept;
48 QueryQueue(
const QueryQueue&) =
delete;
49 QueryQueue& operator=(
const QueryQueue&) =
delete;
60 template <
typename... Args>
64 template <
typename... Args>
65 void Push(
const Query& query,
const Args&... args);
80 struct ParamsHolder
final {
83 USERVER_NAMESPACE::utils::AnyMovable any_params{};
85 detail::QueryParameters params_proxy;
88 const UserTypes& GetConnectionUserTypes()
const;
90 void DoPush(
CommandControl cc,
const Query& query, ParamsHolder&& params);
92 void ValidateUsage()
const;
95 detail::ConnectionPtr conn_;
97 struct QueriesStorage;
98 USERVER_NAMESPACE::utils::FastPimpl<QueriesStorage, 48, 8> queries_storage_;
101template <
typename... Args>
103 const Args&... args) {
104 ParamsHolder holder{};
105 auto& params = holder.any_params
106 .Emplace<detail::StaticQueryParameters<
sizeof...(args)>>();
107 params.Write(GetConnectionUserTypes(), args...);
108 holder.params_proxy = detail::QueryParameters{params};
109 DoPush(cc, query, std::move(holder));
112template <
typename... Args>
113void QueryQueue::
Push(
const Query& query,
const Args&... args) {
114 Push(default_cc_, query, args...);