Skip to content

Commit

Permalink
Update apcaccess crate to fix occasional hang.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrolGenhald committed Sep 28, 2024
1 parent a8a64c3 commit 1a2d006
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 80 deletions.
109 changes: 33 additions & 76 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "prometheus_apcupsd_exporter"
version = "0.1.0"
version = "0.4.0"
edition = "2021"

[dependencies]
apcaccess = "0.1.3"
apcaccess = { version = "0.1.3", git = "https://github.com/AndrolGenhald/apcaccess-rs" }
chrono = "0.4.38"
futures = "0.3.30"
num = "0.4.3"
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
})()?;

let mut apc = APCThrottledAccess::new(Default::default(), Duration::from_secs(5));
let mut apc = APCThrottledAccess::new(APCAccessConfig { timeout: Duration::from_millis(500), ..Default::default() }, Duration::from_secs(1));

render_prometheus(server_options.into(), (), |_request, _| async move {
let data = apc.fetch().await.map_err(|_| "error fetching data from apcupsd")?;
let data = apc.fetch().await.map_err(|e| format!("error fetching data from apcupsd: {e}\n"))?;

let rendered_result = render_metrics(data);

Expand Down

0 comments on commit 1a2d006

Please sign in to comment.