Wrap Searcher in an Arc only in main

pull/813/head
Ana Gelez 4 years ago committed by Mina Galić
parent 54496c1527
commit ee6a562404
Signed by: igalic
GPG Key ID: ACFEFF7F6A123A86

@ -6,13 +6,7 @@ use chrono::{Datelike, Utc};
use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl};
use itertools::Itertools;
use riker::actors::*;
use std::{
cmp,
fs::create_dir_all,
io,
path::Path,
sync::{Arc, Mutex},
};
use std::{cmp, fs::create_dir_all, io, path::Path, sync::Mutex};
use tantivy::{
collector::TopDocs, directory::MmapDirectory, schema::*, Index, IndexReader, IndexWriter,
ReloadPolicy, TantivyError, Term,
@ -93,7 +87,7 @@ impl Searcher {
///
/// The panic messages are normally explicit enough for a human to
/// understand how to fix the issue when they see it.
pub fn new(db_pool: DbPool) -> Arc<Self> {
pub fn new(db_pool: DbPool) -> Self {
// We try to open the index a first time
let searcher = match Self::open(
&CONFIG.search_index,
@ -169,7 +163,7 @@ Then try to restart Plume
e => Err(e).unwrap(),
},
Err(_) => panic!("Unexpected error while opening search index"),
Ok(s) => Arc::new(s),
Ok(s) => s,
}
}

@ -78,7 +78,7 @@ Then try to restart Plume.
}
let workpool = ScheduledThreadPool::with_name("worker {}", num_cpus::get());
let searcher = Searcher::new(dbpool.clone());
let searcher = Arc::new(Searcher::new(dbpool.clone()));
let commiter = searcher.clone();
workpool.execute_with_fixed_delay(
Duration::from_secs(5),

Loading…
Cancel
Save