Start votes processor.
(self, cancel_token: &CancellationToken)
| 84 | |
| 85 | /// Start votes processor. |
| 86 | pub(crate) fn run(self, cancel_token: &CancellationToken) -> JoinAll<JoinHandle<()>> { |
| 87 | let num_workers = COMMANDS_HANDLERS_WORKERS + VOTES_CLOSERS_WORKERS + 2; // Status checker + auto closer |
| 88 | let mut workers_handles = Vec::with_capacity(num_workers); |
| 89 | |
| 90 | // Launch commands handler workers |
| 91 | for _ in 0..COMMANDS_HANDLERS_WORKERS { |
| 92 | let cmds_handler = CommandsHandler::new(self.db.clone(), self.gh.clone(), self.cmds_rx.clone()); |
| 93 | let cmds_handler_handle = cmds_handler.run(cancel_token.clone()); |
| 94 | workers_handles.push(cmds_handler_handle); |
| 95 | } |
| 96 | |
| 97 | // Launch votes closer workers |
| 98 | for _ in 0..VOTES_CLOSERS_WORKERS { |
| 99 | let votes_closer = VotesCloser::new(self.db.clone(), self.gh.clone()); |
| 100 | let votes_closer_handler = votes_closer.run(cancel_token.clone()); |
| 101 | workers_handles.push(votes_closer_handler); |
| 102 | } |
| 103 | |
| 104 | // Launch status checker |
| 105 | let status_checker = StatusChecker::new(self.db.clone(), self.cmds_tx.clone()); |
| 106 | let status_checker_handle = status_checker.run(cancel_token.clone()); |
| 107 | workers_handles.push(status_checker_handle); |
| 108 | |
| 109 | // Launch votes auto closer |
| 110 | let votes_auto_closer = VotesAutoCloser::new(self.db.clone(), self.gh.clone()); |
| 111 | let votes_auto_closer_handle = votes_auto_closer.run(cancel_token.clone()); |
| 112 | workers_handles.push(votes_auto_closer_handle); |
| 113 | |
| 114 | future::join_all(workers_handles) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /// Worker that receives commands from the queue and executes them. Commands |
no test coverage detected