mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-23 05:00:06 +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]]
|
||||
name = "milli"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/meilisearch/milli.git?rev=794fce7#794fce7bff3e3461a7f3954fd97f58f8232e5a8e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bstr",
|
||||
|
@ -38,7 +38,7 @@ main_error = "0.1.0"
|
||||
meilisearch-error = { path = "../MeiliSearch/meilisearch-error" }
|
||||
meilisearch-tokenizer = { git = "https://github.com/meilisearch/Tokenizer.git", branch = "main" }
|
||||
memmap = "0.7.0"
|
||||
milli = { path = "../milli/milli" }
|
||||
milli = { git = "https://github.com/meilisearch/milli.git", rev = "794fce7" }
|
||||
mime = "0.3.16"
|
||||
once_cell = "1.5.2"
|
||||
rand = "0.7.3"
|
||||
|
@ -59,10 +59,8 @@ impl Data {
|
||||
//Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_update_status(&self, index: impl AsRef<str>, uid: u64) -> anyhow::Result<Option<UpdateStatus>> {
|
||||
todo!()
|
||||
//self.index_controller.update_status(index, uid)
|
||||
pub async 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
|
||||
}
|
||||
|
||||
pub async fn get_updates_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus>> {
|
||||
|
@ -150,8 +150,13 @@ impl IndexController {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn update_status(&self, index: String, id: u64) -> anyhow::Result<Option<UpdateStatus>> {
|
||||
todo!()
|
||||
pub async fn update_status(&self, index: String, id: u64) -> anyhow::Result<Option<UpdateStatus>> {
|
||||
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>> {
|
||||
|
@ -38,6 +38,11 @@ enum UpdateMsg<D> {
|
||||
uuid: Uuid,
|
||||
ret: oneshot::Sender<Result<Vec<UpdateStatus>>>,
|
||||
},
|
||||
GetUpdate {
|
||||
uuid: Uuid,
|
||||
ret: oneshot::Sender<Result<Option<UpdateStatus>>>,
|
||||
id: u64,
|
||||
}
|
||||
}
|
||||
|
||||
struct UpdateActor<D, S> {
|
||||
@ -81,6 +86,9 @@ where
|
||||
Some(ListUpdates { uuid, ret }) => {
|
||||
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 => {}
|
||||
}
|
||||
}
|
||||
@ -154,6 +162,17 @@ where
|
||||
}).await
|
||||
.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)]
|
||||
@ -199,6 +218,13 @@ where
|
||||
let _ = self.sender.send(msg).await;
|
||||
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 {
|
||||
|
@ -133,7 +133,7 @@ async fn get_update_status(
|
||||
data: web::Data<Data>,
|
||||
path: web::Path<UpdateParam>,
|
||||
) -> 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 {
|
||||
Ok(Some(meta)) => {
|
||||
let json = serde_json::to_string(&meta).unwrap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user