11 #ifndef PQXX_H_TRANSACTOR 12 #define PQXX_H_TRANSACTOR 15 #include <type_traits> 17 #include "pqxx/connection.hxx" 18 #include "pqxx/transaction.hxx" 96 template<
typename TRANSACTION_CALLBACK>
97 inline auto perform(TRANSACTION_CALLBACK &&callback,
int attempts = 3)
98 -> std::invoke_result_t<TRANSACTION_CALLBACK>
101 throw std::invalid_argument{
102 "Zero or negative number of attempts passed to pqxx::perform()."};
104 for (; attempts > 0; --attempts)
108 return std::invoke(callback);
"Help, I don't know whether transaction was committed successfully!"
Definition: except.hxx:103
We can't tell whether our last statement succeeded.
Definition: except.hxx:136
Internal error in libpqxx library.
Definition: except.hxx:154
The backend saw itself forced to roll back the ongoing transaction.
Definition: except.hxx:110
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:22
Exception class for lost or failed backend connection.
Definition: except.hxx:64
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:97