mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-13 00:06:24 +00:00
feat(http): calculate updates' and uuids' dbs size
This commit is contained in:
@ -41,6 +41,9 @@ impl<S: UuidStore> UuidResolverActor<S> {
|
||||
Some(SnapshotRequest { path, ret }) => {
|
||||
let _ = ret.send(self.handle_snapshot(path).await);
|
||||
}
|
||||
Some(GetSize { ret }) => {
|
||||
let _ = ret.send(self.handle_get_size().await);
|
||||
}
|
||||
// all senders have been dropped, need to quit.
|
||||
None => break,
|
||||
}
|
||||
@ -86,6 +89,10 @@ impl<S: UuidStore> UuidResolverActor<S> {
|
||||
self.store.insert(uid, uuid).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_get_size(&self) -> Result<u64> {
|
||||
self.store.get_size().await
|
||||
}
|
||||
}
|
||||
|
||||
fn is_index_uid_valid(uid: &str) -> bool {
|
||||
|
@ -75,4 +75,13 @@ impl UuidResolverHandle for UuidResolverHandleImpl {
|
||||
.await
|
||||
.expect("Uuid resolver actor has been killed")?)
|
||||
}
|
||||
|
||||
async fn get_size(&self) -> Result<u64> {
|
||||
let (ret, receiver) = oneshot::channel();
|
||||
let msg = UuidResolveMsg::GetSize { ret };
|
||||
let _ = self.sender.send(msg).await;
|
||||
Ok(receiver
|
||||
.await
|
||||
.expect("Uuid resolver actor has been killed")?)
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ use tokio::sync::oneshot;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::Result;
|
||||
|
||||
pub enum UuidResolveMsg {
|
||||
Get {
|
||||
uid: String,
|
||||
@ -29,4 +30,7 @@ pub enum UuidResolveMsg {
|
||||
path: PathBuf,
|
||||
ret: oneshot::Sender<Result<Vec<Uuid>>>,
|
||||
},
|
||||
GetSize {
|
||||
ret: oneshot::Sender<Result<u64>>,
|
||||
},
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ pub trait UuidResolverHandle {
|
||||
async fn delete(&self, name: String) -> anyhow::Result<Uuid>;
|
||||
async fn list(&self) -> anyhow::Result<Vec<(String, Uuid)>>;
|
||||
async fn snapshot(&self, path: PathBuf) -> Result<Vec<Uuid>>;
|
||||
async fn get_size(&self) -> Result<u64>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
@ -8,6 +8,7 @@ use heed::{
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::{Result, UuidError, UUID_STORE_SIZE};
|
||||
use crate::helpers::EnvSizer;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait UuidStore {
|
||||
@ -19,6 +20,7 @@ pub trait UuidStore {
|
||||
async fn list(&self) -> Result<Vec<(String, Uuid)>>;
|
||||
async fn insert(&self, name: String, uuid: Uuid) -> Result<()>;
|
||||
async fn snapshot(&self, path: PathBuf) -> Result<Vec<Uuid>>;
|
||||
async fn get_size(&self) -> Result<u64>;
|
||||
}
|
||||
|
||||
pub struct HeedUuidStore {
|
||||
@ -151,4 +153,8 @@ impl UuidStore for HeedUuidStore {
|
||||
})
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn get_size(&self) -> Result<u64> {
|
||||
Ok(self.env.size())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user