diff --git a/meilisearch/src/routes/mod.rs b/meilisearch/src/routes/mod.rs index 1c1465582..7cf886017 100644 --- a/meilisearch/src/routes/mod.rs +++ b/meilisearch/src/routes/mod.rs @@ -15,6 +15,7 @@ use tracing::debug; use crate::analytics::Analytics; use crate::extractors::authentication::policies::*; use crate::extractors::authentication::GuardedData; +use crate::search_queue::SearchQueue; use crate::Opt; const PAGINATION_DEFAULT_LIMIT: usize = 20; @@ -385,10 +386,12 @@ pub async fn get_health( req: HttpRequest, index_scheduler: Data, auth_controller: Data, + search_queue: Data, analytics: web::Data, ) -> Result { analytics.health_seen(&req); + search_queue.health().unwrap(); index_scheduler.health().unwrap(); auth_controller.health().unwrap(); diff --git a/meilisearch/src/search_queue.rs b/meilisearch/src/search_queue.rs index c0d7c7706..6d5044d20 100644 --- a/meilisearch/src/search_queue.rs +++ b/meilisearch/src/search_queue.rs @@ -117,4 +117,14 @@ impl SearchQueue { self.sender.send(sender).await.map_err(|_| MeilisearchHttpError::SearchLimiterIsDown)?; receiver.await.map_err(|_| MeilisearchHttpError::TooManySearchRequests(self.capacity)) } + + /// Returns `Ok(())` if everything seems normal. + /// Returns `Err(MeilisearchHttpError::SearchLimiterIsDown)` if the search limiter seems down. + pub fn health(&self) -> Result<(), MeilisearchHttpError> { + if self.sender.is_closed() { + Err(MeilisearchHttpError::SearchLimiterIsDown) + } else { + Ok(()) + } + } }