Skip to content

Commit

Permalink
chore: edge will now give a warning when failing to load from cache o…
Browse files Browse the repository at this point in the history
…n startup (#456)
  • Loading branch information
sighphyre authored May 7, 2024
1 parent 45552e7 commit f567cce
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions server/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,21 @@ async fn hydrate_from_persistent_storage(
storage: Arc<dyn EdgePersistence>,
) {
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);
Expand Down Expand Up @@ -134,8 +146,12 @@ async fn get_data_source(args: &EdgeArgs) -> Option<Arc<dyn EdgePersistence>> {
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));
}

Expand Down

0 comments on commit f567cce

Please sign in to comment.