mod actor; mod handle_impl; mod message; mod update_store; use std::path::PathBuf; use thiserror::Error; use tokio::sync::mpsc; use uuid::Uuid; use crate::index::UpdateResult; use crate::index_controller::{UpdateMeta, UpdateStatus}; use actor::UpdateActor; use message::UpdateMsg; pub use handle_impl::UpdateActorHandleImpl; pub type Result = std::result::Result; type UpdateStore = update_store::UpdateStore; type PayloadData = std::result::Result>; #[cfg(test)] use mockall::automock; #[derive(Debug, Error)] pub enum UpdateError { #[error("error with update: {0}")] Error(Box), #[error("Update {0} doesn't exist.")] UnexistingUpdate(u64), } pub struct UpdateStoreInfo { /// Size of the update store in bytes. pub size: u64, /// Uuid of the currently processing update if it exists pub processing: Option, } #[async_trait::async_trait] #[cfg_attr(test, automock(type Data=Vec;))] pub trait UpdateActorHandle { type Data: AsRef<[u8]> + Sized + 'static + Sync + Send; async fn get_all_updates_status(&self, uuid: Uuid) -> Result>; async fn update_status(&self, uuid: Uuid, id: u64) -> Result; async fn delete(&self, uuid: Uuid) -> Result<()>; async fn snapshot(&self, uuids: Vec, path: PathBuf) -> Result<()>; async fn get_info(&self) -> Result; async fn update( &self, meta: UpdateMeta, data: mpsc::Receiver>, uuid: Uuid, ) -> Result; }