Skip to content

Commit

Permalink
try remove spawn_blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
ragibkl committed Aug 26, 2024
1 parent 885eb27 commit 5229389
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/logs_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn extract_query_logs(content: &str) -> HashMap<String, Vec<QueryLog>> {

for part in content.split("\n---\n").map(|s| s.trim()) {
let Ok(raw_log) = serde_yaml::from_str::<RawLog>(part) else {
tracing::info!("LogsStore extract_query_logs fail to extract part: {part}");
tracing::info!("extract_query_logs fail to extract part: {part}");
continue;
};

Expand Down Expand Up @@ -137,19 +137,13 @@ impl LogsStore {

tracing::info!("LogsStore read_dnstap_logs");
let content = read_dnstap_logs().await;
tracing::info!(
"LogsStore read_dnstap_logs. DONE, content.len={}",
content.len()
);
let content_len = content.len();
tracing::info!("LogsStore read_dnstap_logs. DONE, content_len={content_len}");

tracing::info!("LogsStore extract_query_logs");
let logs_hash_map = tokio::task::spawn_blocking(move || extract_query_logs(&content))
.await
.unwrap();
tracing::info!(
"LogsStore extract_query_logs. DONE, logs_hash_map.len()={}",
logs_hash_map.len()
);
let logs_hash_map = extract_query_logs(&content);
let logs_hash_map_len = logs_hash_map.len();
tracing::info!("LogsStore extract_query_logs. DONE, logs_hash_map_len={logs_hash_map_len}");

tracing::info!("LogsStore logs_hash_map");
self.merge_logs(logs_hash_map);
Expand Down

0 comments on commit 5229389

Please sign in to comment.