fff_search/dbs/
db_healthcheck.rs1use crate::error::Result;
2
3#[derive(Debug, Clone)]
5pub struct DbHealth {
6 pub path: String,
8 pub disk_size: u64,
10 pub entry_counts: Vec<(&'static str, u64)>,
12 pub healthy: bool,
14}
15
16pub trait DbHealthChecker {
17 fn get_env(&self) -> &heed::Env;
18 fn is_healthy(&self) -> bool;
19 fn count_entries(&self) -> Result<Vec<(&'static str, u64)>>;
21
22 fn get_health(&self) -> Result<DbHealth> {
24 let env = self.get_env();
25
26 let size = env
27 .real_disk_size()
28 .map_err(crate::error::Error::GenericDbError)?;
29 let path = env.path().to_string_lossy().to_string();
30 let entry_counts = self.count_entries()?;
31
32 Ok(DbHealth {
33 path,
34 disk_size: size,
35 entry_counts,
36 healthy: self.is_healthy(),
37 })
38 }
39}