mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
feat: add deep health check for drainer (#3396)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: dracarys18 <karthikey.hegde@juspay.in>
This commit is contained in:
@ -15,6 +15,22 @@ pub enum DrainerError {
|
||||
ParsingError(error_stack::Report<common_utils::errors::ParsingError>),
|
||||
#[error("Unexpected error occurred: {0}")]
|
||||
UnexpectedError(String),
|
||||
#[error("I/O: {0}")]
|
||||
IoError(std::io::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error, Clone, serde::Serialize)]
|
||||
pub enum HealthCheckError {
|
||||
#[error("Database health check is failing with error: {message}")]
|
||||
DbError { message: String },
|
||||
#[error("Redis health check is failing with error: {message}")]
|
||||
RedisError { message: String },
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for DrainerError {
|
||||
fn from(err: std::io::Error) -> Self {
|
||||
Self::IoError(err)
|
||||
}
|
||||
}
|
||||
|
||||
pub type DrainerResult<T> = error_stack::Result<T, DrainerError>;
|
||||
@ -30,3 +46,13 @@ impl From<error_stack::Report<redis::errors::RedisError>> for DrainerError {
|
||||
Self::RedisError(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl actix_web::ResponseError for HealthCheckError {
|
||||
fn status_code(&self) -> reqwest::StatusCode {
|
||||
use reqwest::StatusCode;
|
||||
|
||||
match self {
|
||||
Self::DbError { .. } | Self::RedisError { .. } => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user