From 5a59deb75dc0b44b6c25cb7d70a2f19902ac9d28 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Wed, 13 Mar 2024 17:58:17 +0100 Subject: [PATCH] feat: limit connection timeout --- src/database.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/database.rs b/src/database.rs index 820a65c..5d4e876 100644 --- a/src/database.rs +++ b/src/database.rs @@ -37,7 +37,7 @@ impl DatabaseSource { pub fn check(&self, year: &str, ignore_exports_since: &str) -> Result, ()> { match Pool::new(self.0.as_str()) { Ok(pool) => { - if let Ok(mut connection) = pool.get_conn() { + if let Ok(mut connection) = pool.try_get_conn(Duration::from_secs(3)) { return match connection.exec_map( SQL_QUERY, params! {"year" => year, "ignore_exports_since" => ignore_exports_since}, @@ -67,7 +67,7 @@ impl DatabaseSource { ) -> Result, ()> { match Pool::new(self.0.as_str()) { Ok(pool) => { - if let Ok(mut connection) = pool.get_conn() { + if let Ok(mut connection) = pool.try_get_conn(Duration::from_secs(3)) { return match connection.exec_map( EXPORT_QUERY, params! {"year" => year, "ignore_exports_since" => ignore_exports_since},