Adding delete method
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -214,6 +214,7 @@ namespace daggy {
|
||||
kill_ = kill;
|
||||
running_ = false;
|
||||
|
||||
logger_.updateDAGRunState(runID_, RunState::KILLED);
|
||||
if (blocking) {
|
||||
while (true) {
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user