2021-03-23 11:00:50 +01:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
use tokio::sync::oneshot;
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
2021-05-31 16:03:39 +02:00
|
|
|
use crate::index::{Checked, Document, SearchQuery, SearchResult, Settings};
|
2021-04-22 10:14:29 +02:00
|
|
|
use crate::index_controller::{Failed, IndexStats, Processed, Processing};
|
2021-04-01 16:44:42 +02:00
|
|
|
|
2021-04-22 10:14:29 +02:00
|
|
|
use super::{IndexMeta, IndexResult, IndexSettings};
|
2021-03-23 11:00:50 +01:00
|
|
|
|
2021-06-17 17:03:43 +02:00
|
|
|
#[allow(clippy::large_enum_variant)]
|
2021-03-23 11:00:50 +01:00
|
|
|
pub enum IndexMsg {
|
|
|
|
CreateIndex {
|
|
|
|
uuid: Uuid,
|
|
|
|
primary_key: Option<String>,
|
2021-04-22 10:14:29 +02:00
|
|
|
ret: oneshot::Sender<IndexResult<IndexMeta>>,
|
2021-03-23 11:00:50 +01:00
|
|
|
},
|
|
|
|
Update {
|
2021-04-13 17:14:02 +02:00
|
|
|
uuid: Uuid,
|
2021-04-22 10:14:29 +02:00
|
|
|
meta: Processing,
|
|
|
|
data: Option<std::fs::File>,
|
|
|
|
ret: oneshot::Sender<IndexResult<Result<Processed, Failed>>>,
|
2021-03-23 11:00:50 +01:00
|
|
|
},
|
|
|
|
Search {
|
|
|
|
uuid: Uuid,
|
|
|
|
query: SearchQuery,
|
|
|
|
ret: oneshot::Sender<anyhow::Result<SearchResult>>,
|
|
|
|
},
|
|
|
|
Settings {
|
|
|
|
uuid: Uuid,
|
2021-05-10 17:30:09 +02:00
|
|
|
ret: oneshot::Sender<IndexResult<Settings<Checked>>>,
|
2021-03-23 11:00:50 +01:00
|
|
|
},
|
|
|
|
Documents {
|
|
|
|
uuid: Uuid,
|
|
|
|
attributes_to_retrieve: Option<Vec<String>>,
|
|
|
|
offset: usize,
|
|
|
|
limit: usize,
|
2021-04-22 10:14:29 +02:00
|
|
|
ret: oneshot::Sender<IndexResult<Vec<Document>>>,
|
2021-03-23 11:00:50 +01:00
|
|
|
},
|
|
|
|
Document {
|
|
|
|
uuid: Uuid,
|
|
|
|
attributes_to_retrieve: Option<Vec<String>>,
|
|
|
|
doc_id: String,
|
2021-04-22 10:14:29 +02:00
|
|
|
ret: oneshot::Sender<IndexResult<Document>>,
|
2021-03-23 11:00:50 +01:00
|
|
|
},
|
|
|
|
Delete {
|
|
|
|
uuid: Uuid,
|
2021-04-22 10:14:29 +02:00
|
|
|
ret: oneshot::Sender<IndexResult<()>>,
|
2021-03-23 11:00:50 +01:00
|
|
|
},
|
|
|
|
GetMeta {
|
|
|
|
uuid: Uuid,
|
2021-04-22 10:14:29 +02:00
|
|
|
ret: oneshot::Sender<IndexResult<IndexMeta>>,
|
2021-03-23 11:00:50 +01:00
|
|
|
},
|
|
|
|
UpdateIndex {
|
|
|
|
uuid: Uuid,
|
|
|
|
index_settings: IndexSettings,
|
2021-04-22 10:14:29 +02:00
|
|
|
ret: oneshot::Sender<IndexResult<IndexMeta>>,
|
2021-03-23 11:00:50 +01:00
|
|
|
},
|
|
|
|
Snapshot {
|
|
|
|
uuid: Uuid,
|
|
|
|
path: PathBuf,
|
2021-04-22 10:14:29 +02:00
|
|
|
ret: oneshot::Sender<IndexResult<()>>,
|
2021-03-23 11:00:50 +01:00
|
|
|
},
|
2021-04-28 16:43:49 +02:00
|
|
|
Dump {
|
|
|
|
uuid: Uuid,
|
|
|
|
path: PathBuf,
|
2021-05-10 20:24:14 +02:00
|
|
|
ret: oneshot::Sender<IndexResult<()>>,
|
2021-04-28 16:43:49 +02:00
|
|
|
},
|
2021-04-01 16:44:42 +02:00
|
|
|
GetStats {
|
|
|
|
uuid: Uuid,
|
2021-04-22 10:14:29 +02:00
|
|
|
ret: oneshot::Sender<IndexResult<IndexStats>>,
|
2021-04-01 16:44:42 +02:00
|
|
|
},
|
2021-03-23 11:00:50 +01:00
|
|
|
}
|