#pragma once

#include <maps/libs/pgpool/include/pgpool3.h>

#include <pqxx/pqxx>

#include <string>

namespace maps::mrc::eye {

pgpool3::TransactionHandle getMasterWriteTxn(pgpool3::Pool& pool);

pgpool3::TransactionHandle getSlaveTxn(pgpool3::Pool& pool, std::string token={});

std::string getNewToken(pgpool3::Pool& pool);

inline std::string getToken(pqxx::transaction_base& txn) { return pgpool3::generateToken(txn); }

std::string commit(pqxx::transaction_base& txn); // return token

} // namespace maps::mrc::eye