Queue as many jobs as we can on ping

This change isn't incredibly important, but in cases where more than one
jobs server is running, and one happens to get a heavy amount of new job
traffic while the others get very few, it is possible that we can end up
with unprocessed jobs in the DB while not every worker is busy. This
change exausts our worker queue on ping if there are jobs available
This commit is contained in:
asonix 2019-05-25 17:10:32 -05:00
parent 875eec57dd
commit 0a509e0271

View file

@ -173,11 +173,14 @@ where
trace!("Checkdb");
for (queue, workers) in self.cache.iter_mut() {
while !workers.is_empty() {
if let Some(request) = workers.pop_front() {
if let Some(job) = self.storage.request_job(queue, request.worker_id)? {
request.addr.do_send(ProcessJob::new(job));
} else {
workers.push_back(request);
break;
}
}
}
}