From 60dc2736811940e72cc3032b7877f77cb9fade98 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Sun, 5 Apr 2026 01:07:42 -0300 Subject: [PATCH] fix: use CachedSecret struct instead of tuples in sync methods --- Cargo.toml | 2 ++ src/core/secrets/mod.rs | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2853c48b..9f65275d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -232,6 +232,8 @@ rust-embed = { workspace = true, optional = true } mockito = { workspace = true } tempfile = { workspace = true } bigdecimal = { workspace = true } + +[dependencies] ureq = { version = "2", features = ["json"] } [dev-dependencies] diff --git a/src/core/secrets/mod.rs b/src/core/secrets/mod.rs index eaafcdda..2eac0bbd 100644 --- a/src/core/secrets/mod.rs +++ b/src/core/secrets/mod.rs @@ -929,8 +929,8 @@ impl SecretsManager { fn get_cached_sync(&self, path: &str) -> Option> { let cache = self.cache.read().ok()?; let entry = cache.get(path)?; - if entry.1.elapsed() < std::time::Duration::from_secs(self.cache_ttl) { - Some(entry.0.clone()) + if entry.expires_at.elapsed() < std::time::Duration::from_secs(self.cache_ttl) { + Some(entry.data.clone()) } else { None } @@ -939,7 +939,10 @@ impl SecretsManager { fn cache_secret_sync(&self, path: &str, data: HashMap) { if self.cache_ttl > 0 { if let Ok(mut cache) = self.cache.write() { - cache.insert(path.to_string(), (data, std::time::Instant::now())); + cache.insert(path.to_string(), CachedSecret { + data, + expires_at: std::time::Instant::now(), + }); } } }