mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-10 21:44:34 +01:00
implement get single udpate
This commit is contained in:
parent
a9c7b73744
commit
7d28f8cff0
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1870,6 +1870,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "milli"
|
name = "milli"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
source = "git+https://github.com/meilisearch/milli.git?rev=794fce7#794fce7bff3e3461a7f3954fd97f58f8232e5a8e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bstr",
|
"bstr",
|
||||||
|
@ -38,7 +38,7 @@ main_error = "0.1.0"
|
|||||||
meilisearch-error = { path = "../MeiliSearch/meilisearch-error" }
|
meilisearch-error = { path = "../MeiliSearch/meilisearch-error" }
|
||||||
meilisearch-tokenizer = { git = "https://github.com/meilisearch/Tokenizer.git", branch = "main" }
|
meilisearch-tokenizer = { git = "https://github.com/meilisearch/Tokenizer.git", branch = "main" }
|
||||||
memmap = "0.7.0"
|
memmap = "0.7.0"
|
||||||
milli = { path = "../milli/milli" }
|
milli = { git = "https://github.com/meilisearch/milli.git", rev = "794fce7" }
|
||||||
mime = "0.3.16"
|
mime = "0.3.16"
|
||||||
once_cell = "1.5.2"
|
once_cell = "1.5.2"
|
||||||
rand = "0.7.3"
|
rand = "0.7.3"
|
||||||
|
@ -59,10 +59,8 @@ impl Data {
|
|||||||
//Ok(())
|
//Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
pub async fn get_update_status(&self, index: impl AsRef<str>, uid: u64) -> anyhow::Result<Option<UpdateStatus>> {
|
||||||
pub fn get_update_status(&self, index: impl AsRef<str>, uid: u64) -> anyhow::Result<Option<UpdateStatus>> {
|
self.index_controller.update_status(index.as_ref().to_string(), uid).await
|
||||||
todo!()
|
|
||||||
//self.index_controller.update_status(index, uid)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_updates_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus>> {
|
pub async fn get_updates_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus>> {
|
||||||
|
@ -150,8 +150,13 @@ impl IndexController {
|
|||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_status(&self, index: String, id: u64) -> anyhow::Result<Option<UpdateStatus>> {
|
pub async fn update_status(&self, index: String, id: u64) -> anyhow::Result<Option<UpdateStatus>> {
|
||||||
todo!()
|
let uuid = self.uuid_resolver
|
||||||
|
.resolve(index)
|
||||||
|
.await?
|
||||||
|
.context("index not found")?;
|
||||||
|
let result = self.update_handle.update_status(uuid, id).await?;
|
||||||
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn all_update_status(&self, index: String) -> anyhow::Result<Vec<UpdateStatus>> {
|
pub async fn all_update_status(&self, index: String) -> anyhow::Result<Vec<UpdateStatus>> {
|
||||||
|
@ -38,6 +38,11 @@ enum UpdateMsg<D> {
|
|||||||
uuid: Uuid,
|
uuid: Uuid,
|
||||||
ret: oneshot::Sender<Result<Vec<UpdateStatus>>>,
|
ret: oneshot::Sender<Result<Vec<UpdateStatus>>>,
|
||||||
},
|
},
|
||||||
|
GetUpdate {
|
||||||
|
uuid: Uuid,
|
||||||
|
ret: oneshot::Sender<Result<Option<UpdateStatus>>>,
|
||||||
|
id: u64,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UpdateActor<D, S> {
|
struct UpdateActor<D, S> {
|
||||||
@ -81,6 +86,9 @@ where
|
|||||||
Some(ListUpdates { uuid, ret }) => {
|
Some(ListUpdates { uuid, ret }) => {
|
||||||
let _ = ret.send(self.handle_list_updates(uuid).await);
|
let _ = ret.send(self.handle_list_updates(uuid).await);
|
||||||
} ,
|
} ,
|
||||||
|
Some(GetUpdate { uuid, ret, id }) => {
|
||||||
|
let _ = ret.send(self.handle_get_update(uuid, id).await);
|
||||||
|
}
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,6 +162,17 @@ where
|
|||||||
}).await
|
}).await
|
||||||
.map_err(|e| UpdateError::Error(Box::new(e)))?
|
.map_err(|e| UpdateError::Error(Box::new(e)))?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async fn handle_get_update(&self, uuid: Uuid, id: u64) -> Result<Option<UpdateStatus>> {
|
||||||
|
let store = self.store
|
||||||
|
.get(&uuid)
|
||||||
|
.await?
|
||||||
|
.ok_or(UpdateError::UnexistingIndex(uuid))?;
|
||||||
|
let result = store.meta(id)
|
||||||
|
.map_err(|e| UpdateError::Error(Box::new(e)))?;
|
||||||
|
Ok(result)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -199,6 +218,13 @@ where
|
|||||||
let _ = self.sender.send(msg).await;
|
let _ = self.sender.send(msg).await;
|
||||||
receiver.await.expect("update actor killed.")
|
receiver.await.expect("update actor killed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn update_status(&self, uuid: Uuid, id: u64) -> Result<Option<UpdateStatus>> {
|
||||||
|
let (ret, receiver) = oneshot::channel();
|
||||||
|
let msg = UpdateMsg::GetUpdate { uuid, id, ret };
|
||||||
|
let _ = self.sender.send(msg).await;
|
||||||
|
receiver.await.expect("update actor killed.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MapUpdateStoreStore {
|
struct MapUpdateStoreStore {
|
||||||
|
@ -133,7 +133,7 @@ async fn get_update_status(
|
|||||||
data: web::Data<Data>,
|
data: web::Data<Data>,
|
||||||
path: web::Path<UpdateParam>,
|
path: web::Path<UpdateParam>,
|
||||||
) -> Result<HttpResponse, ResponseError> {
|
) -> Result<HttpResponse, ResponseError> {
|
||||||
let result = data.get_update_status(&path.index_uid, path.update_id);
|
let result = data.get_update_status(&path.index_uid, path.update_id).await;
|
||||||
match result {
|
match result {
|
||||||
Ok(Some(meta)) => {
|
Ok(Some(meta)) => {
|
||||||
let json = serde_json::to_string(&meta).unwrap();
|
let json = serde_json::to_string(&meta).unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user