refactor: apply zero-unwrap policy and optimize locks in store.rs and handlers

This commit is contained in:
Riz Ashraf committed 2026-09-21 11:34:21 +01:00
1 parent 9f24e66d88
commit 8afbf97b11
33 files changed
+3127 -3207

No files matched your search

+10 -6
View File
@@ -60,7 +60,7 @@ impl MemoryIndex {
let body_field = self.body_field;
let type_field = self.type_field;
let namespace_field = self.namespace_field;
tokio::task::spawn_blocking(move || {
let doc = doc!(
id_field => e.name.clone(),
@@ -83,7 +83,7 @@ impl MemoryIndex {
let body_field = self.body_field;
let type_field = self.type_field;
let namespace_field = self.namespace_field;
tokio::task::spawn_blocking(move || {
let doc = doc!(
id_field => t.id.clone(),
@@ -106,7 +106,11 @@ impl MemoryIndex {
Ok(())
})
.await
.unwrap_or_else(|_| Err(tantivy::TantivyError::SystemError("Commit task panicked".to_string())))
.unwrap_or_else(|_| {
Err(tantivy::TantivyError::SystemError(
"Commit task panicked".to_string(),
))
})
}
pub fn search(
@@ -171,7 +175,7 @@ impl MemoryIndex {
let body_field = self.body_field;
let type_field = self.type_field;
let namespace_field = self.namespace_field;
tokio::task::spawn_blocking(move || {
let doc = doc!(
id_field => s.name.clone(),
@@ -194,7 +198,7 @@ impl MemoryIndex {
let body_field = self.body_field;
let type_field = self.type_field;
let namespace_field = self.namespace_field;
tokio::task::spawn_blocking(move || {
let doc = doc!(
id_field => a.id.clone(),
@@ -225,7 +229,7 @@ impl MemoryIndex {
tokio::task::spawn_blocking(move || {
let writer = writer.lock().unwrap();
for e in entities {
writer.add_document(doc!(
id_field => e.name.clone(),