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>,
|
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 {
|
impl Notmuch {
|
||||||
pub fn with_config<P: AsRef<Path>>(config_path: P) -> Notmuch {
|
pub fn with_config<P: AsRef<Path>>(config_path: P) -> Notmuch {
|
||||||
Notmuch {
|
Notmuch {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ use log::info;
|
|||||||
use notmuch::Notmuch;
|
use notmuch::Notmuch;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::postgres::PgPool;
|
use sqlx::postgres::PgPool;
|
||||||
|
use tokio::join;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
use crate::{config::Config, newsreader, nm, tantivy::TantivyConnection, Query};
|
use crate::{config::Config, newsreader, nm, tantivy::TantivyConnection, Query};
|
||||||
@ -286,6 +287,8 @@ impl QueryRoot {
|
|||||||
Ok(total)
|
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))]
|
#[instrument(skip_all, fields(query=query))]
|
||||||
async fn search<'ctx>(
|
async fn search<'ctx>(
|
||||||
&self,
|
&self,
|
||||||
@ -328,18 +331,17 @@ impl QueryRoot {
|
|||||||
let query: Query = query.parse()?;
|
let query: Query = query.parse()?;
|
||||||
info!("newsreader_query {query:?}");
|
info!("newsreader_query {query:?}");
|
||||||
|
|
||||||
let newsreader_results = newsreader_search(
|
let newsreader_fut = newsreader_search(
|
||||||
pool,
|
pool,
|
||||||
newsreader_after,
|
newsreader_after,
|
||||||
newsreader_before,
|
newsreader_before,
|
||||||
first,
|
first,
|
||||||
last,
|
last,
|
||||||
&query,
|
&query,
|
||||||
)
|
);
|
||||||
.await?;
|
let notmuch_fut =
|
||||||
let notmuch_results =
|
notmuch_search(nm, notmuch_after, notmuch_before, first, last, &query);
|
||||||
notmuch_search(nm, notmuch_after, notmuch_before, first, last, &query).await?;
|
let tantivy_fut = tantivy_search(
|
||||||
let tantivy_results = tantivy_search(
|
|
||||||
tantivy,
|
tantivy,
|
||||||
pool,
|
pool,
|
||||||
tantivy_after,
|
tantivy_after,
|
||||||
@ -347,8 +349,13 @@ impl QueryRoot {
|
|||||||
first,
|
first,
|
||||||
last,
|
last,
|
||||||
&query,
|
&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!(
|
info!(
|
||||||
"newsreader_results ({}) notmuch_results ({}) tantivy_results ({})",
|
"newsreader_results ({}) notmuch_results ({}) tantivy_results ({})",
|
||||||
newsreader_results.len(),
|
newsreader_results.len(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user