Browse Source

Wrap Searcher in an Arc only in main

pull/813/head
Ana Gelez 4 months ago
parent
commit
ee6a562404
Signed by: igalic <me+github@igalic.co> GPG Key ID: ACFEFF7F6A123A86
2 changed files with 4 additions and 10 deletions
  1. +3
    -9
      plume-models/src/search/searcher.rs
  2. +1
    -1
      src/main.rs

+ 3
- 9
plume-models/src/search/searcher.rs View File

@@ -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,
}
}



+ 1
- 1
src/main.rs View File

@@ -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