Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: edge will now give a warning when failing to load from cache #456

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading