11 #ifndef PQXX_TRANSACTOR_HXX
12 #define PQXX_TRANSACTOR_HXX
14 #if !defined(PQXX_HEADER_PRE)
15 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
19 #include <type_traits>
99 template<
typename TRANSACTION_CALLBACK>
100 inline std::invoke_result_t<TRANSACTION_CALLBACK>
101 perform(TRANSACTION_CALLBACK &&callback,
int attempts,
sl loc = sl::current())
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);
183 template<
typename TRANSACTION_CALLBACK>
184 inline std::invoke_result_t<TRANSACTION_CALLBACK>
185 perform(TRANSACTION_CALLBACK &&callback,
sl loc = sl::current())
187 return perform(callback, 3, loc);
Exception class for lost or failed backend connection.
Definition: except.hxx:316
"Help, I don't know whether transaction was committed successfully!"
Definition: except.hxx:451
Internal error in libpqxx library.
Definition: except.hxx:558
Exception class for mis-communication with the server.
Definition: except.hxx:419
We can't tell whether our last statement succeeded.
Definition: except.hxx:524
The backend saw itself forced to roll back the ongoing transaction.
Definition: except.hxx:476
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
std::source_location sl
Convenience alias for std::source_location. It's just too long.
Definition: types.hxx:38
std::invoke_result_t< TRANSACTION_CALLBACK > perform(TRANSACTION_CALLBACK &&callback, int attempts, sl loc=sl::current())
Simple way to execute a transaction with automatic retry.
Definition: transactor.hxx:101