server: attempt concurrency with graphql::search and fail
This commit is contained in:
parent
39ea5c5458
commit
7c943afc2b
@ -465,6 +465,8 @@ pub struct Notmuch {
|
||||
config_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
// TODO: rewrite to use tokio::process::Command and make everything async to see if that helps with
|
||||
// concurrency being more parallel.
|
||||
impl Notmuch {
|
||||
pub fn with_config<P: AsRef<Path>>(config_path: P) -> Notmuch {
|
||||
Notmuch {
|
||||
|
||||
@ -9,6 +9,7 @@ use log::info;
|
||||
use notmuch::Notmuch;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::postgres::PgPool;
|
||||
use tokio::join;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::{config::Config, newsreader, nm, tantivy::TantivyConnection, Query};
|
||||
@ -286,6 +287,8 @@ impl QueryRoot {
|
||||
Ok(total)
|
||||
}
|
||||
|
||||
// TODO: this function doesn't get parallelism, possibly because notmuch is sync and blocks,
|
||||
// rewrite that with tokio::process:Command
|
||||
#[instrument(skip_all, fields(query=query))]
|
||||
async fn search<'ctx>(
|
||||
&self,
|
||||
@ -328,18 +331,17 @@ impl QueryRoot {
|
||||
let query: Query = query.parse()?;
|
||||
info!("newsreader_query {query:?}");
|
||||
|
||||
let newsreader_results = newsreader_search(
|
||||
let newsreader_fut = newsreader_search(
|
||||
pool,
|
||||
newsreader_after,
|
||||
newsreader_before,
|
||||
first,
|
||||
last,
|
||||
&query,
|
||||
)
|
||||
.await?;
|
||||
let notmuch_results =
|
||||
notmuch_search(nm, notmuch_after, notmuch_before, first, last, &query).await?;
|
||||
let tantivy_results = tantivy_search(
|
||||
);
|
||||
let notmuch_fut =
|
||||
notmuch_search(nm, notmuch_after, notmuch_before, first, last, &query);
|
||||
let tantivy_fut = tantivy_search(
|
||||
tantivy,
|
||||
pool,
|
||||
tantivy_after,
|
||||
@ -347,8 +349,13 @@ impl QueryRoot {
|
||||
first,
|
||||
last,
|
||||
&query,
|
||||
)
|
||||
.await?;
|
||||
);
|
||||
let (newsreader_results, notmuch_results, tantivy_results) =
|
||||
join!(newsreader_fut, notmuch_fut, tantivy_fut);
|
||||
|
||||
let newsreader_results = newsreader_results?;
|
||||
let notmuch_results = notmuch_results?;
|
||||
let tantivy_results = tantivy_results?;
|
||||
info!(
|
||||
"newsreader_results ({}) notmuch_results ({}) tantivy_results ({})",
|
||||
newsreader_results.len(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user