refactor uuid resolver

This commit is contained in:
mpostma 2021-09-22 10:49:59 +02:00
parent 60518449fc
commit def737edee
13 changed files with 223 additions and 246 deletions

View file

@ -8,17 +8,17 @@ use futures::{lock::Mutex, stream::StreamExt};
use log::{error, trace};
use tokio::sync::{mpsc, oneshot, RwLock};
use update_actor::UpdateActorHandle;
use uuid_resolver::UuidResolverHandle;
use super::error::{DumpActorError, Result};
use super::{DumpInfo, DumpMsg, DumpStatus, DumpTask};
use crate::index_controller::{update_actor, uuid_resolver};
use crate::index_controller::uuid_resolver::UuidResolverSender;
use crate::index_controller::update_actor;
pub const CONCURRENT_DUMP_MSG: usize = 10;
pub struct DumpActor<UuidResolver, Update> {
pub struct DumpActor<Update> {
inbox: Option<mpsc::Receiver<DumpMsg>>,
uuid_resolver: UuidResolver,
uuid_resolver: UuidResolverSender,
update: Update,
dump_path: PathBuf,
lock: Arc<Mutex<()>>,
@ -32,14 +32,13 @@ fn generate_uid() -> String {
Utc::now().format("%Y%m%d-%H%M%S%3f").to_string()
}
impl<UuidResolver, Update> DumpActor<UuidResolver, Update>
impl<Update> DumpActor<Update>
where
UuidResolver: UuidResolverHandle + Send + Sync + Clone + 'static,
Update: UpdateActorHandle + Send + Sync + Clone + 'static,
{
pub fn new(
inbox: mpsc::Receiver<DumpMsg>,
uuid_resolver: UuidResolver,
uuid_resolver: UuidResolverSender,
update: Update,
dump_path: impl AsRef<Path>,
index_db_size: usize,

View file

@ -2,6 +2,8 @@ use std::path::Path;
use tokio::sync::{mpsc, oneshot};
use crate::index_controller::uuid_resolver::UuidResolverSender;
use super::error::Result;
use super::{DumpActor, DumpActorHandle, DumpInfo, DumpMsg};
@ -30,7 +32,7 @@ impl DumpActorHandle for DumpActorHandleImpl {
impl DumpActorHandleImpl {
pub fn new(
path: impl AsRef<Path>,
uuid_resolver: crate::index_controller::uuid_resolver::UuidResolverHandleImpl,
uuid_resolver: UuidResolverSender,
update: crate::index_controller::update_actor::UpdateActorHandleImpl,
index_db_size: usize,
update_db_size: usize,

View file

@ -7,7 +7,8 @@ use milli::update::Setting;
use serde::{Deserialize, Deserializer, Serialize};
use uuid::Uuid;
use crate::index_controller::{self, uuid_resolver::HeedUuidStore, IndexMetadata};
use crate::index_controller::uuid_resolver::store::HeedUuidStore;
use crate::index_controller::{self, IndexMetadata};
use crate::index_controller::{asc_ranking_rule, desc_ranking_rule};
use crate::{
index::Unchecked,

View file

@ -5,7 +5,7 @@ use log::info;
use serde::{Deserialize, Serialize};
use crate::index::Index;
use crate::index_controller::{update_actor::UpdateStore, uuid_resolver::HeedUuidStore};
use crate::index_controller::{update_actor::UpdateStore, uuid_resolver::store::HeedUuidStore};
use crate::options::IndexerOpts;
#[derive(Serialize, Deserialize, Debug)]

View file

@ -16,8 +16,10 @@ pub use actor::DumpActor;
pub use handle_impl::*;
pub use message::DumpMsg;
use super::{update_actor::UpdateActorHandle, uuid_resolver::UuidResolverHandle};
use super::update_actor::UpdateActorHandle;
use super::uuid_resolver::UuidResolverSender;
use crate::index_controller::dump_actor::error::DumpActorError;
use crate::index_controller::uuid_resolver::UuidResolverMsg;
use crate::options::IndexerOpts;
use error::Result;
@ -149,18 +151,17 @@ pub fn load_dump(
Ok(())
}
struct DumpTask<U, P> {
struct DumpTask<P> {
path: PathBuf,
uuid_resolver: U,
uuid_resolver: UuidResolverSender,
update_handle: P,
uid: String,
update_db_size: usize,
index_db_size: usize,
}
impl<U, P> DumpTask<U, P>
impl<P> DumpTask<P>
where
U: UuidResolverHandle + Send + Sync + Clone + 'static,
P: UpdateActorHandle + Send + Sync + Clone + 'static,
{
@ -179,7 +180,7 @@ where
let mut meta_file = File::create(&meta_path)?;
serde_json::to_writer(&mut meta_file, &meta)?;
let uuids = self.uuid_resolver.dump(temp_dump_path.clone()).await?;
let uuids = UuidResolverMsg::dump(&self.uuid_resolver, temp_dump_path.clone()).await?;
self.update_handle
.dump(uuids, temp_dump_path.clone())