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

upd #1

Merged
merged 1 commit into from
Dec 21, 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
27 changes: 15 additions & 12 deletions lib/enrichment/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,24 @@ fn fmt_enrichment_table(
name: &'static str,
tables: &Arc<ArcSwap<Option<TableMap>>>,
) -> std::fmt::Result {
// Load the current state of the tables (this is a lock-free operation).
let tables = tables.load();
match **tables {
Some(ref tables) => {
let mut tables = tables.iter().fold(String::from("("), |mut s, (key, _)| {
s.push_str(key);
s.push_str(", ");
s
});

tables.truncate(std::cmp::max(tables.len(), 0));
tables.push(')');

write!(f, "{} {}", name, tables)
// Check if the tables are loaded or still in the loading state.
match &**tables {
Some(ref tables) => {
// Map the keys to &str and join them with a comma.
let table_names = tables
.keys()
.map(|s| s.as_str())
.collect::<Vec<_>>()
.join(", ");
write!(f, "{} ({})", name, table_names)
}
None => {
// If the tables are still loading, indicate the loading state.
write!(f, "{} loading", name)
}
None => write!(f, "{} loading", name),
}
}

Expand Down