From cd78d3c1c7668dbde6503aaff4576ddea04e6222 Mon Sep 17 00:00:00 2001 From: Neshura Date: Mon, 6 May 2024 22:21:04 +0200 Subject: [PATCH] Reduced connection timeouts and added some logging --- src/bot.rs | 2 ++ src/lemmy.rs | 4 ++-- src/main.rs | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bot.rs b/src/bot.rs index 7916920..5a598f6 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -102,6 +102,8 @@ pub(crate) async fn run() { let series = config.series.clone(); for series in series { + let info_msg = format!("Handling Series {}", series.slug); + info!(info_msg); if handle_series(&series, &communities, &lemmy, &config, &mut post_history) .await .is_err() diff --git a/src/lemmy.rs b/src/lemmy.rs index e9c0ad8..32f45ce 100644 --- a/src/lemmy.rs +++ b/src/lemmy.rs @@ -215,7 +215,7 @@ impl Lemmy { match serde_json::from_str::(response) { Ok(data) => Ok(data), Err(e) => { - let err_msg = format!("{e}"); + let err_msg = format!("{e} while parsing JSON"); error!(err_msg); Err(()) } @@ -226,7 +226,7 @@ impl Lemmy { match serde_json::from_str::>(response) { Ok(mut data) => Ok(data.remove("post_view").expect("Element should be present")), Err(e) => { - let err_msg = format!("{e}"); + let err_msg = format!("{e} while parsing JSON HashMap"); error!(err_msg); Err(()) } diff --git a/src/main.rs b/src/main.rs index fc93d6a..e5242da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,8 +12,8 @@ mod fetchers; pub static HTTP_CLIENT: Lazy = Lazy::new(|| { Client::builder() - .timeout(Duration::seconds(30).to_std().unwrap()) - .connect_timeout(Duration::seconds(30).to_std().unwrap()) + .timeout(Duration::seconds(10).to_std().unwrap()) + .connect_timeout(Duration::seconds(10).to_std().unwrap()) .build() .expect("build client") });