#include <userver/storages/postgres/query_queue.hpp>
A container to enqueue queries in FIFO order and execute them all within a single network round-trip.
Acquired from storages::postgres::Cluster, one is expected to Push some queries into the queue and then Collect them into vector of results.
From a client point of view Collect is transactional: either all the queries succeed or Collect rethrows the first error encountered. However, this is NOT the case for the server: server treats all the provided queries independently and is likely to execute subsequent queries even after prior failures.
Collect call.Definition at line 43 of file query_queue.hpp.
Public Member Functions | |
| QueryQueue (CommandControl default_cc, detail::ConnectionPtr &&conn) | |
| QueryQueue (QueryQueue &&) noexcept | |
| QueryQueue & | operator= (QueryQueue &&) noexcept |
| QueryQueue (const QueryQueue &)=delete | |
| QueryQueue & | operator= (const QueryQueue &)=delete |
| void | Reserve (std::size_t size) |
| Reserve internal storage to hold this amount of queries. | |
| template<typename... Args> | |
| void | Push (CommandControl cc, const Query &query, const Args &... args) |
| void | Push (CommandControl cc, const Query &query, const ParameterStore &store) |
| template<typename... Args> | |
| void | Push (const Query &query, const Args &... args) |
| Add a query into the queue with default command-control. | |
| void | Push (const Query &query, const ParameterStore &store) |
| std::vector< ResultSet > | Collect (TimeoutDuration timeout) |
| std::vector< ResultSet > | Collect () |
|
nodiscard |
Collect results of all the queued queries, with default timeout. Either returns a vector of N ResultSets, where N is the number of queries enqueued, or rethrow the first error encountered, be that a query execution error or a timeout.
|
nodiscard |
Collect results of all the queued queries, with specified timeout. Either returns a vector of N ResultSets, where N is the number of queries enqueued, or rethrow the first error encountered, be that a query execution error or a timeout.
| void storages::postgres::QueryQueue::Push | ( | CommandControl | cc, |
| const Query & | query, | ||
| const Args &... | args ) |
Add a query into the queue with specified command-control. CommandControl is used as following: 'execute' is used as a timeout for preparing the statement (if needed), 'statement' is used as a statement timeout for later execution.
Definition at line 106 of file query_queue.hpp.
| void storages::postgres::QueryQueue::Push | ( | const Query & | query, |
| const Args &... | args ) |
Add a query into the queue with default command-control.
Definition at line 115 of file query_queue.hpp.