mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-12 07:36:29 +00:00
feat(http): implement is_indexing for stats
This commit is contained in:
@ -72,6 +72,9 @@ where
|
||||
Some(Snapshot { uuid, path, ret }) => {
|
||||
let _ = ret.send(self.handle_snapshot(uuid, path).await);
|
||||
}
|
||||
Some(IsLocked { uuid, ret }) => {
|
||||
let _ = ret.send(self.handle_is_locked(uuid).await);
|
||||
}
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
@ -223,4 +226,14 @@ where
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_is_locked(&self, uuid: Uuid) -> Result<bool> {
|
||||
let store = self
|
||||
.store
|
||||
.get(uuid)
|
||||
.await?
|
||||
.ok_or(UpdateError::UnexistingIndex(uuid))?;
|
||||
|
||||
Ok(store.update_lock.is_locked())
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,12 @@ use std::path::{Path, PathBuf};
|
||||
use tokio::sync::{mpsc, oneshot};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::index_controller::IndexActorHandle;
|
||||
|
||||
use super::{
|
||||
MapUpdateStoreStore, PayloadData, Result, UpdateActor, UpdateActorHandle, UpdateMeta,
|
||||
UpdateMsg, UpdateStatus,
|
||||
};
|
||||
use crate::index_controller::IndexActorHandle;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct UpdateActorHandleImpl<D> {
|
||||
@ -36,6 +37,7 @@ where
|
||||
Ok(Self { sender })
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl<D> UpdateActorHandle for UpdateActorHandleImpl<D>
|
||||
where
|
||||
@ -43,29 +45,12 @@ where
|
||||
{
|
||||
type Data = D;
|
||||
|
||||
async fn update(
|
||||
&self,
|
||||
meta: UpdateMeta,
|
||||
data: mpsc::Receiver<PayloadData<Self::Data>>,
|
||||
uuid: Uuid,
|
||||
) -> Result<UpdateStatus> {
|
||||
let (ret, receiver) = oneshot::channel();
|
||||
let msg = UpdateMsg::Update {
|
||||
uuid,
|
||||
data,
|
||||
meta,
|
||||
ret,
|
||||
};
|
||||
let _ = self.sender.send(msg).await;
|
||||
receiver.await.expect("update actor killed.")
|
||||
}
|
||||
async fn get_all_updates_status(&self, uuid: Uuid) -> Result<Vec<UpdateStatus>> {
|
||||
let (ret, receiver) = oneshot::channel();
|
||||
let msg = UpdateMsg::ListUpdates { uuid, ret };
|
||||
let _ = self.sender.send(msg).await;
|
||||
receiver.await.expect("update actor killed.")
|
||||
}
|
||||
|
||||
async fn update_status(&self, uuid: Uuid, id: u64) -> Result<UpdateStatus> {
|
||||
let (ret, receiver) = oneshot::channel();
|
||||
let msg = UpdateMsg::GetUpdate { uuid, id, ret };
|
||||
@ -93,4 +78,28 @@ where
|
||||
let _ = self.sender.send(msg).await;
|
||||
receiver.await.expect("update actor killed.")
|
||||
}
|
||||
|
||||
async fn update(
|
||||
&self,
|
||||
meta: UpdateMeta,
|
||||
data: mpsc::Receiver<PayloadData<Self::Data>>,
|
||||
uuid: Uuid,
|
||||
) -> Result<UpdateStatus> {
|
||||
let (ret, receiver) = oneshot::channel();
|
||||
let msg = UpdateMsg::Update {
|
||||
uuid,
|
||||
data,
|
||||
meta,
|
||||
ret,
|
||||
};
|
||||
let _ = self.sender.send(msg).await;
|
||||
receiver.await.expect("update actor killed.")
|
||||
}
|
||||
|
||||
async fn is_locked(&self, uuid: Uuid) -> Result<bool> {
|
||||
let (ret, receiver) = oneshot::channel();
|
||||
let msg = UpdateMsg::IsLocked { uuid, ret };
|
||||
let _ = self.sender.send(msg).await;
|
||||
receiver.await.expect("update actor killed.")
|
||||
}
|
||||
}
|
||||
|
@ -34,4 +34,8 @@ pub enum UpdateMsg<D> {
|
||||
path: PathBuf,
|
||||
ret: oneshot::Sender<Result<()>>,
|
||||
},
|
||||
IsLocked {
|
||||
uuid: Uuid,
|
||||
ret: oneshot::Sender<Result<bool>>,
|
||||
},
|
||||
}
|
||||
|
@ -52,4 +52,5 @@ pub trait UpdateActorHandle {
|
||||
data: mpsc::Receiver<PayloadData<Self::Data>>,
|
||||
uuid: Uuid,
|
||||
) -> Result<UpdateStatus>;
|
||||
async fn is_locked(&self, uuid: Uuid) -> Result<bool>;
|
||||
}
|
||||
|
Reference in New Issue
Block a user