implement upload
This commit is contained in:
parent
9fbcd52e16
commit
5f013f9efa
1 changed files with 27 additions and 3 deletions
|
|
@ -23,6 +23,9 @@
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <pqxx/pqxx>
|
||||||
|
#include <functional>
|
||||||
|
#include <cluster/db_types.hpp>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "uploader.hpp"
|
#include "uploader.hpp"
|
||||||
|
|
||||||
|
|
@ -99,10 +102,31 @@ void Uploader::thread_run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Uploader::upload_task([[maybe_unused]]std::unique_ptr<OutputType> task) {
|
bool Uploader::upload_task(std::unique_ptr<OutputType> task) {
|
||||||
|
|
||||||
// make sure any task that is uploaded isn't halted in the database
|
// make sure any task that is uploaded isn't halted in the database
|
||||||
|
auto task_upload_lambda = [](
|
||||||
|
pqxx::work *txn,
|
||||||
|
const db::uuid_t *target,
|
||||||
|
std::vector<std::string> *sim_log,
|
||||||
|
std::vector<std::string> *sim_error
|
||||||
|
) {
|
||||||
|
txn->exec_params0(
|
||||||
|
"UPDATE sim_outputs SET sim_log = $1, error_log = $2 WHERE id = $3 AND part_status != 'halted';",
|
||||||
|
*sim_log,
|
||||||
|
*sim_error,
|
||||||
|
*target
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
std::cout << "[UPLOADER] Task uploaded!" << std::endl;
|
std::function<void(
|
||||||
return true;
|
pqxx::work*,
|
||||||
|
const db::uuid_t*,
|
||||||
|
std::vector<std::string>*,
|
||||||
|
std::vector<std::string>*
|
||||||
|
)> task_upload_func = task_upload_lambda;
|
||||||
|
|
||||||
|
DEBUG_PRINT("Updating task " + db::to_string(task->id));
|
||||||
|
|
||||||
|
return this->conn->send_request(&task_upload_func, &(task->id), &(task->get_content().first), &(task->get_content().second));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue