Skip to content

Commit

Permalink
fix: restart when heartbeat times out (rapiz1#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
rapiz1 authored Mar 28, 2022
1 parent 636bdbd commit feb8c2d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ pub async fn run_client(
shutdown_rx: broadcast::Receiver<bool>,
service_rx: mpsc::Receiver<ServiceChange>,
) -> Result<()> {
let config = config.client.ok_or_else(|| anyhow!(
let config = config.client.ok_or_else(|| {
anyhow!(
"Try to run as a client, but the configuration is missing. Please add the `[client]` block"
))?;
)
})?;

match config.transport.transport_type {
TransportType::Tcp => {
Expand Down Expand Up @@ -459,8 +461,7 @@ impl<T: 'static + Transport> ControlChannel<T> {
}
},
_ = time::sleep(Duration::from_secs(self.heartbeat_timeout)), if self.heartbeat_timeout != 0 => {
warn!("Heartbeat timed out");
break;
return Err(anyhow!("Heartbeat timed out"))
}
_ = &mut self.shutdown_rx => {
break;
Expand Down

0 comments on commit feb8c2d

Please sign in to comment.