Skip to content

Commit

Permalink
Merge pull request #8 from ReCodEx/sweeping-skeletons
Browse files Browse the repository at this point in the history
Sweeping skeletons
  • Loading branch information
Martin Kruliš committed Oct 9, 2020
2 parents 0f39ce1 + 067964a commit 3933e31
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 106 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ set(SOURCE_FILES
src/worker.h
src/worker.cpp
src/notifier/status_notifier.h
src/notifier/http_status_notifier.h
src/notifier/http_status_notifier.cpp
src/notifier/empty_status_notifier.h
src/reactor/reactor.h
src/reactor/reactor.cpp
Expand Down
1 change: 0 additions & 1 deletion src/broker_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace fs = boost::filesystem;
#include "broker_connect.h"
#include "config/broker_config.h"
#include "config/log_config.h"
#include "notifier/http_status_notifier.h"
#include "reactor/command_holder.h"


Expand Down
23 changes: 17 additions & 6 deletions src/handlers/status_notifier_handler.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "../helpers/curl.h"
#include "status_notifier_handler.h"

#include <map>
#include <sstream>
#include <thread>
#include <chrono>

#include "../helpers/curl.h"
#include "status_notifier_handler.h"

const std::string status_notifier_handler::TYPE_ERROR = "error";
const std::string status_notifier_handler::TYPE_JOB_STATUS = "job-status";
Expand Down Expand Up @@ -47,9 +50,17 @@ void status_notifier_handler::on_request(
ss << "/" << id;
}

try {
helpers::curl_post(ss.str(), config_.port, params, config_.username, config_.password);
} catch (helpers::curl_exception &exception) {
logger_->critical("curl failed: {}", exception.what());
std::size_t retries = 4; // we come by this value using digital suction
auto delay = std::chrono::seconds(1);
while (retries > 0) {
--retries;
try {
helpers::curl_post(ss.str(), config_.port, params, config_.username, config_.password);
return; // success, nothing else to try
} catch (helpers::curl_exception &exception) {
logger_->critical("curl failed: {}", exception.what());
std::this_thread::sleep_for(delay);
delay *= 2; // exponentially growing waiting intervals are cool
}
}
}
46 changes: 0 additions & 46 deletions src/notifier/http_status_notifier.cpp

This file was deleted.

51 changes: 0 additions & 51 deletions src/notifier/http_status_notifier.h

This file was deleted.

0 comments on commit 3933e31

Please sign in to comment.