Use set indexer options instead of create a default one

This commit is contained in:
many 2021-09-08 10:44:23 +02:00
parent c0f9c891f5
commit 08138c7c23
No known key found for this signature in database
GPG Key ID: 2CEF23B75189EACA
3 changed files with 15 additions and 6 deletions

View File

@ -31,9 +31,12 @@ pub struct IndexActor<S> {
} }
impl<S: IndexStore + Sync + Send> IndexActor<S> { impl<S: IndexStore + Sync + Send> IndexActor<S> {
pub fn new(receiver: mpsc::Receiver<IndexMsg>, store: S) -> anyhow::Result<Self> { pub fn new(
let options = IndexerOpts::default(); receiver: mpsc::Receiver<IndexMsg>,
let update_handler = UpdateHandler::new(&options)?; store: S,
options: &IndexerOpts,
) -> anyhow::Result<Self> {
let update_handler = UpdateHandler::new(options)?;
let update_handler = Arc::new(update_handler); let update_handler = Arc::new(update_handler);
let receiver = Some(receiver); let receiver = Some(receiver);
Ok(Self { Ok(Self {

View File

@ -1,3 +1,4 @@
use crate::option::IndexerOpts;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use tokio::sync::{mpsc, oneshot}; use tokio::sync::{mpsc, oneshot};
@ -148,11 +149,15 @@ impl IndexActorHandle for IndexActorHandleImpl {
} }
impl IndexActorHandleImpl { impl IndexActorHandleImpl {
pub fn new(path: impl AsRef<Path>, index_size: usize) -> anyhow::Result<Self> { pub fn new(
path: impl AsRef<Path>,
index_size: usize,
options: &IndexerOpts,
) -> anyhow::Result<Self> {
let (sender, receiver) = mpsc::channel(100); let (sender, receiver) = mpsc::channel(100);
let store = MapIndexStore::new(path, index_size); let store = MapIndexStore::new(path, index_size);
let actor = IndexActor::new(receiver, store)?; let actor = IndexActor::new(receiver, store, options)?;
tokio::task::spawn(actor.run()); tokio::task::spawn(actor.run());
Ok(Self { sender }) Ok(Self { sender })
} }

View File

@ -110,7 +110,8 @@ impl IndexController {
std::fs::create_dir_all(&path)?; std::fs::create_dir_all(&path)?;
let uuid_resolver = uuid_resolver::UuidResolverHandleImpl::new(&path)?; let uuid_resolver = uuid_resolver::UuidResolverHandleImpl::new(&path)?;
let index_handle = index_actor::IndexActorHandleImpl::new(&path, index_size)?; let index_handle =
index_actor::IndexActorHandleImpl::new(&path, index_size, &options.indexer_options)?;
let update_handle = update_actor::UpdateActorHandleImpl::new( let update_handle = update_actor::UpdateActorHandleImpl::new(
index_handle.clone(), index_handle.clone(),
&path, &path,