mod index_actor; mod update_actor; mod uuid_resolver; mod update_store; use tokio::sync::oneshot; use super::IndexController; use uuid::Uuid; use super::IndexMetadata; use tokio::fs::File; use super::UpdateMeta; pub struct ActorIndexController { uuid_resolver: uuid_resolver::UuidResolverHandle, index_handle: index_actor::IndexActorHandle, update_handle: update_actor::UpdateActorHandle, } impl ActorIndexController { pub fn new() -> Self { let uuid_resolver = uuid_resolver::UuidResolverHandle::new(); let index_actor = index_actor::IndexActorHandle::new(); let update_handle = update_actor::UpdateActorHandle::new(index_actor.clone()); Self { uuid_resolver, index_handle: index_actor, update_handle } } } enum IndexControllerMsg { CreateIndex { uuid: Uuid, primary_key: Option, ret: oneshot::Sender>, }, Shutdown, } #[async_trait::async_trait(?Send)] impl IndexController for ActorIndexController { async fn add_documents( &self, index: String, method: milli::update::IndexDocumentsMethod, format: milli::update::UpdateFormat, data: File, primary_key: Option, ) -> anyhow::Result { let uuid = self.uuid_resolver.get_or_create(index).await?; let meta = UpdateMeta::DocumentsAddition { method, format, primary_key }; let status = self.update_handle.update(meta, Some(data), uuid).await?; Ok(status) } fn clear_documents(&self, index: String) -> anyhow::Result { todo!() } fn delete_documents(&self, index: String, document_ids: Vec) -> anyhow::Result { todo!() } fn update_settings(&self, index_uid: String, settings: super::Settings) -> anyhow::Result { todo!() } async fn create_index(&self, index_settings: super::IndexSettings) -> anyhow::Result { let super::IndexSettings { name, primary_key } = index_settings; let uuid = self.uuid_resolver.create(name.unwrap()).await?; let index_meta = self.index_handle.create_index(uuid, primary_key).await?; Ok(index_meta) } fn delete_index(&self, index_uid: String) -> anyhow::Result<()> { todo!() } fn swap_indices(&self, index1_uid: String, index2_uid: String) -> anyhow::Result<()> { todo!() } fn index(&self, name: String) -> anyhow::Result>> { todo!() } fn update_status(&self, index: String, id: u64) -> anyhow::Result> { todo!() } fn all_update_status(&self, index: String) -> anyhow::Result> { todo!() } fn list_indexes(&self) -> anyhow::Result> { todo!() } fn update_index(&self, name: String, index_settings: super::IndexSettings) -> anyhow::Result { todo!() } }