From b17d07d089845b70d718c1492d45b70b20e594cc Mon Sep 17 00:00:00 2001 From: Simon Hornby Date: Tue, 7 May 2024 14:44:29 +0200 Subject: [PATCH] chore: edge will now give a warning when failing to load from cache on startup --- server/src/builder.rs | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/server/src/builder.rs b/server/src/builder.rs index 012f41c8..389d8959 100644 --- a/server/src/builder.rs +++ b/server/src/builder.rs @@ -52,9 +52,21 @@ async fn hydrate_from_persistent_storage( storage: Arc, ) { let (token_cache, features_cache, engine_cache) = cache; - let tokens = storage.load_tokens().await.unwrap_or_default(); - let features = storage.load_features().await.unwrap_or_default(); - let refresh_targets = storage.load_refresh_targets().await.unwrap_or_default(); + let tokens = storage.load_tokens().await.unwrap_or_else(|error| { + warn!("Failed to load tokens from cache {error:?}"); + vec![] + }); + let features = storage.load_features().await.unwrap_or_else(|error| { + warn!("Failed to load features from cache {error:?}"); + Default::default() + }); + let refresh_targets = storage + .load_refresh_targets() + .await + .unwrap_or_else(|error| { + warn!("Failed to load refresh targets from cache {error:?}"); + vec![] + }); for token in tokens { tracing::debug!("Hydrating tokens {token:?}"); token_cache.insert(token.token.clone(), token); @@ -134,8 +146,12 @@ async fn get_data_source(args: &EdgeArgs) -> Option> { RedisPersister::new_with_cluster(urls).expect("Failed to connect to redis cluster") }), } - .unwrap_or_else(|| panic!("Could not build a redis persister from redis_args {:?}", - args.redis)); + .unwrap_or_else(|| { + panic!( + "Could not build a redis persister from redis_args {:?}", + args.redis + ) + }); return Some(Arc::new(redis_persister)); }