11 #ifndef PQXX_H_TRANSACTOR
12 #define PQXX_H_TRANSACTOR
14 #if !defined(PQXX_HEADER_PRE)
15 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
19 #include <type_traits>
21 #include "pqxx/connection.hxx"
22 #include "pqxx/transaction.hxx"
100 template<
typename TRANSACTION_CALLBACK>
101 inline auto perform(TRANSACTION_CALLBACK &&callback,
int attempts = 3)
102 -> std::invoke_result_t<TRANSACTION_CALLBACK>
105 throw std::invalid_argument{
106 "Zero or negative number of attempts passed to pqxx::perform()."};
108 for (; attempts > 0; --attempts)
112 return std::invoke(callback);
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:33
auto perform(TRANSACTION_CALLBACK &&callback, int attempts=3) -> std::invoke_result_t< TRANSACTION_CALLBACK >
Simple way to execute a transaction with automatic retry.
Definition: transactor.hxx:101
Exception class for lost or failed backend connection.
Definition: except.hxx:81
Exception class for micommunication with the server.
Definition: except.hxx:103
"Help, I don't know whether transaction was committed successfully!"
Definition: except.hxx:165
The backend saw itself forced to roll back the ongoing transaction.
Definition: except.hxx:178
We can't tell whether our last statement succeeded.
Definition: except.hxx:214
Internal error in libpqxx library.
Definition: except.hxx:242