MeiliSearch/meilisearch-http/src/index_controller/update_actor/mod.rs

45 lines
1.3 KiB
Rust
Raw Normal View History

2021-04-22 10:14:29 +02:00
use std::{collections::HashSet, path::PathBuf};
2021-03-23 11:00:50 +01:00
2021-05-25 09:46:11 +02:00
use actix_http::error::PayloadError;
2021-03-23 11:00:50 +01:00
use tokio::sync::mpsc;
use uuid::Uuid;
use crate::index_controller::{UpdateMeta, UpdateStatus};
use actor::UpdateActor;
use message::UpdateMsg;
use error::Result;
2021-03-23 11:00:50 +01:00
pub use handle_impl::UpdateActorHandleImpl;
2021-05-25 16:33:09 +02:00
pub use store::{UpdateStore, UpdateStoreInfo};
2021-03-23 11:00:50 +01:00
mod actor;
mod handle_impl;
mod message;
pub mod error;
pub mod store;
2021-05-25 09:46:11 +02:00
type PayloadData<D> = std::result::Result<D, PayloadError>;
2021-03-23 11:00:50 +01:00
2021-03-23 16:19:01 +01:00
#[cfg(test)]
use mockall::automock;
2021-03-23 11:00:50 +01:00
#[async_trait::async_trait]
2021-03-23 16:19:01 +01:00
#[cfg_attr(test, automock(type Data=Vec<u8>;))]
2021-03-23 11:00:50 +01:00
pub trait UpdateActorHandle {
type Data: AsRef<[u8]> + Sized + 'static + Sync + Send;
async fn get_all_updates_status(&self, uuid: Uuid) -> Result<Vec<UpdateStatus>>;
async fn update_status(&self, uuid: Uuid, id: u64) -> Result<UpdateStatus>;
async fn delete(&self, uuid: Uuid) -> Result<()>;
2021-05-10 20:24:14 +02:00
async fn snapshot(&self, uuid: HashSet<Uuid>, path: PathBuf) -> Result<()>;
2021-05-25 16:33:09 +02:00
async fn dump(&self, uuids: HashSet<Uuid>, path: PathBuf) -> Result<()>;
2021-04-14 18:55:04 +02:00
async fn get_info(&self) -> Result<UpdateStoreInfo>;
2021-03-23 11:00:50 +01:00
async fn update(
&self,
meta: UpdateMeta,
data: mpsc::Receiver<PayloadData<Self::Data>>,
uuid: Uuid,
2021-03-24 11:29:11 +01:00
) -> Result<UpdateStatus>;
2021-03-23 11:00:50 +01:00
}