isolate the search in another task

In case there is a failure on milli's side that should avoid blocking the tokio main thread
This commit is contained in:
Irevoire
2022-10-27 13:12:42 +02:00
parent b44cc62320
commit 4d9e9f4a9d

View File

@ -153,7 +153,7 @@ pub async fn search_with_url_query(
let mut aggregate = SearchAggregator::from_query(&query, &req);
let index = index_scheduler.index(&index_uid)?;
let search_result = perform_search(&index, query);
let search_result = tokio::task::spawn_blocking(move || perform_search(&index, query)).await?;
if let Ok(ref search_result) = search_result {
aggregate.succeed(search_result);
}
@ -185,7 +185,7 @@ pub async fn search_with_post(
let mut aggregate = SearchAggregator::from_query(&query, &req);
let index = index_scheduler.index(&index_uid)?;
let search_result = perform_search(&index, query);
let search_result = tokio::task::spawn_blocking(move || perform_search(&index, query)).await?;
if let Ok(ref search_result) = search_result {
aggregate.succeed(search_result);
}