diff --git a/CMakeLists.txt b/CMakeLists.txt index ef6e8c8..2d0b5ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/broker_core.h b/src/broker_core.h index d388f9d..13d179e 100644 --- a/src/broker_core.h +++ b/src/broker_core.h @@ -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" diff --git a/src/notifier/http_status_notifier.cpp b/src/notifier/http_status_notifier.cpp deleted file mode 100644 index 93e4d61..0000000 --- a/src/notifier/http_status_notifier.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "http_status_notifier.h" - -http_status_notifier::http_status_notifier(const notifier_config &config, std::shared_ptr logger) - : config_(config), logger_(logger) -{ - if (logger_ == nullptr) { - logger_ = helpers::create_null_logger(); - } -} - -void http_status_notifier::send(const std::string &route, const helpers::curl_params ¶ms) -{ - std::string addr = config_.address + route; - try { - helpers::curl_post(addr, config_.port, params, config_.username, config_.password); - } catch (helpers::curl_exception &e) { - logger_->critical(e.what()); - } -} - -void http_status_notifier::error(const std::string &desc) -{ - send(error_route_, {{"message", desc}}); -} - -void http_status_notifier::rejected_job(const std::string &job_id, const std::string &desc) -{ - rejected_jobs({job_id}, desc); -} - -void http_status_notifier::rejected_jobs(std::vector job_ids, const std::string &desc) -{ - for (auto &id : job_ids) { - send(job_status_route_ + id, {{"status", "FAILED"}, {"message", desc}}); - } -} - -void http_status_notifier::job_done(const std::string &job_id) -{ - send(job_status_route_ + job_id, {{"status", "OK"}}); -} - -void http_status_notifier::job_failed(const std::string &job_id, const std::string &desc) -{ - send(job_status_route_ + job_id, {{"status", "FAILED"}, {"message", desc}}); -} diff --git a/src/notifier/http_status_notifier.h b/src/notifier/http_status_notifier.h deleted file mode 100644 index de41149..0000000 --- a/src/notifier/http_status_notifier.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef RECODEX_HTTP_STATUS_NOTIFIER_H -#define RECODEX_HTTP_STATUS_NOTIFIER_H - -#include "../config/notifier_config.h" -#include "../helpers/curl.h" -#include "../helpers/logger.h" -#include "status_notifier.h" -#include - - -/** - * A status notifier that uses HTTP (specifically the REST API) to notify the frontend of errors. - */ -class http_status_notifier : public status_notifier_interface -{ -private: - /** Configuration of frontend address and connection */ - notifier_config config_; - /** General error route */ - std::string error_route_ = "/error/"; - /** General route for job concerning messages */ - std::string job_status_route_ = "/job-status/"; - - /** Logger class */ - std::shared_ptr logger_; - - /** - * Internal helper function which is used for actual sending of HTTP requests. - * @param route defines route to which base address will be added - * @param params parameters which will be added to request - */ - void send(const std::string &route, const helpers::curl_params ¶ms); - -public: - /** - * @param config configuration of frontend connection - * @param logger a logger object used when errors happen - */ - http_status_notifier(const notifier_config &config, std::shared_ptr logger = nullptr); - - /** Destructor */ - ~http_status_notifier() override = default; - - void error(const std::string &desc) override; - void rejected_job(const std::string &job_id, const std::string &desc = "") override; - void rejected_jobs(std::vector job_ids, const std::string &desc = "") override; - void job_done(const std::string &job_id) override; - void job_failed(const std::string &job_id, const std::string &desc = "") override; -}; - -#endif // RECODEX_HTTP_STATUS_NOTIFIER_H