feat: add deep health check for analytics (#3438)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Kartikeya Hegde
2024-01-31 07:31:15 +00:00
committed by GitHub
parent e331d2d556
commit 7597f3b692
21 changed files with 281 additions and 173 deletions

View File

@ -17,6 +17,7 @@ use storage_impl::config::Database;
use time::PrimitiveDateTime;
use super::{
health_check::HealthCheck,
query::{Aggregate, ToSql, Window},
types::{
AnalyticsCollection, AnalyticsDataSource, DBEnumWrapper, LoadRow, QueryExecutionError,
@ -164,6 +165,17 @@ impl AnalyticsDataSource for SqlxClient {
.change_context(QueryExecutionError::RowExtractionFailure)
}
}
#[async_trait::async_trait]
impl HealthCheck for SqlxClient {
async fn deep_health_check(&self) -> CustomResult<(), QueryExecutionError> {
sqlx::query("SELECT 1")
.fetch_all(&self.pool)
.await
.map(|_| ())
.into_report()
.change_context(QueryExecutionError::DatabaseError)
}
}
impl<'a> FromRow<'a, PgRow> for super::refunds::metrics::RefundMetricRow {
fn from_row(row: &'a PgRow) -> sqlx::Result<Self> {