worker: remove some unwraps
This commit is contained in:
parent
bd01de758f
commit
ba4eb9cf37
|
@ -40,7 +40,7 @@ async fn main() {
|
||||||
let next_task = if workers_active < config.max_workers {
|
let next_task = if workers_active < config.max_workers {
|
||||||
world.dequeue()
|
world.dequeue()
|
||||||
} else {
|
} else {
|
||||||
Err(Duration::from_secs(3600))
|
Err(Duration::from_secs(5))
|
||||||
};
|
};
|
||||||
match next_task {
|
match next_task {
|
||||||
Err(duration) => {
|
Err(duration) => {
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub fn fetch_and_process(
|
||||||
timestamps.sort();
|
timestamps.sort();
|
||||||
let next_interval = if timestamps.len() > 1 {
|
let next_interval = if timestamps.len() > 1 {
|
||||||
((*timestamps.last().unwrap() - timestamps[0]) / (timestamps.len() as i32)
|
((*timestamps.last().unwrap() - timestamps[0]) / (timestamps.len() as i32)
|
||||||
).to_std().unwrap()
|
).to_std().unwrap_or(DEFAULT_INTERVAL)
|
||||||
.min(DEFAULT_INTERVAL)
|
.min(DEFAULT_INTERVAL)
|
||||||
.max(MIN_INTERVAL)
|
.max(MIN_INTERVAL)
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,8 +54,8 @@ pub fn fetch_and_process(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let hosts = hosts.into_iter().collect();
|
let hosts = hosts.into_iter().collect();
|
||||||
tx.send(Message::IntroduceHosts { hosts }).unwrap();
|
let _ = tx.send(Message::IntroduceHosts { hosts });
|
||||||
tx.send(Message::Posts { posts }).unwrap();
|
let _ = tx.send(Message::Posts { posts });
|
||||||
|
|
||||||
tx.send(Message::Fetched {
|
tx.send(Message::Fetched {
|
||||||
host: host.clone(),
|
host: host.clone(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user