Adding delete method

This commit is contained in:
Ian Roddis
2022-02-01 10:32:31 -04:00
parent 3fdd568b00
commit cc7646f386
3 changed files with 28 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ namespace daggy::daggyd {
DAGGY_REST_HANDLER(handleRunDAG); // X
DAGGY_REST_HANDLER(handleValidateDAG); // X
DAGGY_REST_HANDLER(handleGetDAGRun); // X
DAGGY_REST_HANDLER(handleStopDAGRun); // X
DAGGY_REST_HANDLER(handleGetDAGRunState); // X
DAGGY_REST_HANDLER(handleSetDAGRunState); // X
DAGGY_REST_HANDLER(handleGetTask); // X

View File

@@ -138,6 +138,11 @@ namespace daggy::daggyd {
*/
auto specificDAGRunPath = dagRunPath.path("/:runID");
specificDAGRunPath.route(desc_.del("/"))
.bind(&Server::handleStopDAGRun, this)
.produces(MIME(Application, Json))
.response(Http::Code::Ok, "Kill a running dag");
specificDAGRunPath.route(desc_.get("/"))
.bind(&Server::handleGetDAGRun, this)
.produces(MIME(Application, Json))
@@ -445,6 +450,27 @@ namespace daggy::daggyd {
response.send(Pistache::Http::Code::Ok, ss.str());
}
void Server::handleStopDAGRun(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response)
{
if (!handleAuth(request))
return;
if (!request.hasParam(":runID")) {
REQ_RESPONSE(Not_Found, "No runID provided in URL");
}
auto runID = request.param(":runID").as<size_t>();
{
std::lock_guard<std::mutex> lock(runnerGuard_);
auto it = runners_.find(runID);
if (it != runners_.end()) {
it->second->stop(true, false);
}
}
response.send(Pistache::Http::Code::Ok, "");
}
void Server::handleGetDAGRunState(const Pistache::Rest::Request &request,
Pistache::Http::ResponseWriter response)
{

View File

@@ -214,6 +214,7 @@ namespace daggy {
kill_ = kill;
running_ = false;
logger_.updateDAGRunState(runID_, RunState::KILLED);
if (blocking) {
while (true) {
{