initialize Actor system in main, as well as SearcherActor

pull/813/head
Mina Galić 4 vuotta sitten
vanhempi ee6a562404
commit 1dfad6469b
Allekirjoittanut: igalic
GPG avaimen ID: ACFEFF7F6A123A86

1
Cargo.lock generated

@ -2589,6 +2589,7 @@ dependencies = [
"plume-api 0.4.0",
"plume-common 0.4.0",
"plume-models 0.4.0",
"riker 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rocket 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rocket_contrib 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rocket_csrf 0.1.0 (git+https://github.com/fdb-hiroshima/rocket_csrf?rev=29910f2829e7e590a540da3804336577b48c7b31)",

@ -20,6 +20,7 @@ heck = "0.3.0"
lettre = "0.9.2"
lettre_email = "0.9.2"
num_cpus = "1.10"
riker = "0.4"
rocket = "0.4.5"
rocket_contrib = { version = "0.4.5", features = ["json"] }
rocket_i18n = { git = "https://github.com/Plume-org/rocket_i18n", rev = "e922afa7c366038b3433278c03b1456b346074f2" }

@ -6,7 +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::Mutex};
use std::{cmp, fs::create_dir_all, io, path::Path, sync::Arc, sync::Mutex};
use tantivy::{
collector::TopDocs, directory::MmapDirectory, schema::*, Index, IndexReader, IndexWriter,
ReloadPolicy, TantivyError, Term,
@ -66,6 +66,12 @@ impl Receive<UpdateDocument> for SearcherActor {
}
}
impl ActorFactoryArgs<Arc<Searcher>> for SearcherActor {
fn create_args(searcher: Arc<Searcher>) -> Self {
SearcherActor(Arc::try_unwrap(searcher).ok().unwrap())
}
}
impl Searcher {
/// Initializes a new `Searcher`, ready to be used by
/// Plume.

@ -10,8 +10,14 @@ extern crate serde_json;
#[macro_use]
extern crate validator_derive;
extern crate riker;
use clap::App;
use plume_models::{db_conn::init_pool, migrations::IMPORTED_MIGRATIONS, search::Searcher, CONFIG};
use plume_models::{
db_conn::init_pool, migrations::IMPORTED_MIGRATIONS, search::Searcher, search::SearcherActor,
CONFIG,
};
use riker::actors::*;
use rocket_csrf::CsrfFairingBuilder;
use scheduled_thread_pool::ScheduledThreadPool;
use std::process::exit;
@ -77,8 +83,13 @@ Then try to restart Plume.
)
}
let workpool = ScheduledThreadPool::with_name("worker {}", num_cpus::get());
let searcher = Arc::new(Searcher::new(dbpool.clone()));
let sys = SystemBuilder::new().name("plume").create().unwrap();
let _ = sys
.actor_of_args::<SearcherActor, _>("searcher-actor", searcher.clone())
.unwrap();
let commiter = searcher.clone();
workpool.execute_with_fixed_delay(
Duration::from_secs(5),

Ladataan…
Peruuta
Tallenna