failed requests - retry until timeout

This commit is contained in:
Alex Janka 2024-04-25 14:23:10 +10:00
parent ff78898683
commit 5b905129d3
5 changed files with 22 additions and 14 deletions

4
Cargo.lock generated
View file

@ -1155,7 +1155,7 @@ dependencies = [
[[package]]
name = "homekit-controller"
version = "0.6.2"
version = "0.6.3"
dependencies = [
"chacha20poly1305",
"ed25519-dalek",
@ -1178,7 +1178,7 @@ dependencies = [
[[package]]
name = "homekit-exporter"
version = "0.6.2"
version = "0.6.3"
dependencies = [
"chrono",
"clap",

View file

@ -1,6 +1,6 @@
[package]
name = "homekit-controller"
version = "0.6.2"
version = "0.6.3"
edition = "2021"
license = "Apache-2.0"
description = "Partial implementation of the HomeKit controller protocol"

View file

@ -306,22 +306,30 @@ impl DeviceConnection {
}
pub async fn update_characteristics(&mut self) -> Result<(), HomekitError> {
match tokio::time::timeout(
Duration::from_secs(METRIC_GATHER_TIMEOUT_SECS),
self.characteristics_request(true),
)
match tokio::time::timeout(Duration::from_secs(METRIC_GATHER_TIMEOUT_SECS), async {
loop {
match self.characteristics_request(true).await {
Ok(_) => return,
Err(e) => {
log::warn!(
"{}failed to update characteristics: {e:?}",
formatted_name(&self.name)
);
self.socket = None;
}
}
}
})
.await
.map_err(|_| HomekitError::Timeout)
.flatten_result()
{
Ok(r) => Ok(r),
Err(e) => {
Err(_) => {
log::warn!(
"{}failed to update characteristics: {e:?}",
"{}timed out updating characteristics",
formatted_name(&self.name)
);
self.socket = None;
Err(e)
Err(HomekitError::Timeout)
}
}
}

View file

@ -1,6 +1,6 @@
[package]
name = "homekit-exporter"
version = "0.6.2"
version = "0.6.3"
edition = "2021"
license = "Apache-2.0"
description = "Prometheus exporter for HomeKit sensors"

View file

@ -1,7 +1,7 @@
# Maintainer: Alex Janka <alex@alexjanka.com>
pkgname=homekit-logger
pkgver=0.6.2
pkgver=0.6.3
pkgrel=1
pkgdesc="Prometheus exporter for HomeKit sensors"
arch=('x86_64' 'aarch64')