ReCodEx - Task Broker
ReCodEx is complex programmer testing solution, primary targeted to technical universities. It's highly customizable and based on modern technologies.
broker_handler.h
1 #ifndef RECODEX_BROKER_BROKER_HANDLER_H
2 #define RECODEX_BROKER_BROKER_HANDLER_H
3 
4 #include <spdlog/logger.h>
5 
6 #include "../config/broker_config.h"
7 #include "../notifier/status_notifier.h"
8 #include "../reactor/command_holder.h"
9 #include "../reactor/handler_interface.h"
10 #include "../worker_registry.h"
11 
16 {
17 public:
23  broker_handler(std::shared_ptr<const broker_config> config,
24  std::shared_ptr<worker_registry> workers,
25  std::shared_ptr<spdlog::logger> logger);
26 
27  void on_request(const message_container &message, response_cb respond);
28 
29 private:
31  std::shared_ptr<const broker_config> config_;
32 
34  std::shared_ptr<worker_registry> workers_;
35 
37  std::shared_ptr<spdlog::logger> logger_;
38 
40  std::map<worker_registry::worker_ptr, std::chrono::milliseconds> worker_timers_;
41 
43  command_holder worker_commands_;
44 
46  command_holder client_commands_;
47 
52  void process_worker_init(const std::string &identity, const std::vector<std::string> &message, response_cb respond);
53 
58  void process_worker_done(const std::string &identity, const std::vector<std::string> &message, response_cb respond);
59 
64  void process_worker_ping(const std::string &identity, const std::vector<std::string> &message, response_cb respond);
65 
70  void process_worker_progress(
71  const std::string &identity, const std::vector<std::string> &message, response_cb respond);
72 
78  void process_client_eval(const std::string &identity, const std::vector<std::string> &message, response_cb respond);
79 
85  void process_timer(const message_container &message, response_cb respond);
86 
93  bool reassign_request(worker::request_ptr request, response_cb respond);
94 
101  bool assign_queued_request(worker_registry::worker_ptr worker, response_cb respond);
102 
109  bool check_failure_count(worker::request_ptr request, status_notifier_interface &status_notifier);
110 };
111 
112 #endif // RECODEX_BROKER_BROKER_HANDLER_H
std::shared_ptr< request > request_ptr
Definition: worker.h:151
broker_handler(std::shared_ptr< const broker_config > config, std::shared_ptr< worker_registry > workers, std::shared_ptr< spdlog::logger > logger)
std::function< void(const message_container &)> response_cb
std::shared_ptr< worker > worker_ptr
void on_request(const message_container &message, response_cb respond)
Definition: worker.h:147
Definition: worker.h:78