worker: remove some unwraps

This commit is contained in:
Astro 2022-11-03 00:27:16 +01:00
parent bd01de758f
commit ba4eb9cf37
2 changed files with 4 additions and 4 deletions

View File

@ -40,7 +40,7 @@ async fn main() {
let next_task = if workers_active < config.max_workers {
world.dequeue()
} else {
Err(Duration::from_secs(3600))
Err(Duration::from_secs(5))
};
match next_task {
Err(duration) => {

View File

@ -34,7 +34,7 @@ pub fn fetch_and_process(
timestamps.sort();
let next_interval = if timestamps.len() > 1 {
((*timestamps.last().unwrap() - timestamps[0]) / (timestamps.len() as i32)
).to_std().unwrap()
).to_std().unwrap_or(DEFAULT_INTERVAL)
.min(DEFAULT_INTERVAL)
.max(MIN_INTERVAL)
} else {
@ -54,8 +54,8 @@ pub fn fetch_and_process(
}
}
let hosts = hosts.into_iter().collect();
tx.send(Message::IntroduceHosts { hosts }).unwrap();
tx.send(Message::Posts { posts }).unwrap();
let _ = tx.send(Message::IntroduceHosts { hosts });
let _ = tx.send(Message::Posts { posts });
tx.send(Message::Fetched {
host: host.clone(),