#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 41 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) |
template<typename... Args> | |
void | Push (const Query &query, const Args &... args) |
Add a query into the queue with default command-control. | |
std::vector< ResultSet > | Collect (TimeoutDuration timeout) |
std::vector< ResultSet > | Collect () |
std::vector< ResultSet > storages::postgres::QueryQueue::Collect | ( | ) |
Collect results of all the queued queries, with default timeout. Either returns a vector of N ResultSet
s, where N is the number of queries enqueued, or rethrow the first error encountered, be that a query execution error or a timeout.
std::vector< ResultSet > storages::postgres::QueryQueue::Collect | ( | TimeoutDuration | timeout | ) |
Collect results of all the queued queries, with specified timeout. Either returns a vector of N ResultSet
s, 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 102 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 113 of file query_queue.hpp.