mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 00:47:53 +00:00
configurable health threshold
This commit is contained in:
1 parent
be20e105ea
commit
a31ecc01ab
3 files changed
+6
-3
No files matched your search
@@ -63,9 +63,6 @@ pub async fn get_health_check_handler(
|
||||
HealthCheckError::ServerError
|
||||
})?;
|
||||
|
||||
// TODO: Configurability
|
||||
let is_healthy = job_stats.consecutive_failure_count < 10;
|
||||
|
||||
let total_tries = job_stats.total_failure_count.saturating_add(job_stats.total_success_count);
|
||||
|
||||
let total_success_ratio = if total_tries > 0 {
|
||||
@@ -80,6 +77,9 @@ pub async fn get_health_check_handler(
|
||||
0.0
|
||||
};
|
||||
|
||||
let is_healthy =
|
||||
job_stats.consecutive_failure_count < server_state.consecutive_failure_unhealthy_threshold;
|
||||
|
||||
let response = HealthCheckResponse {
|
||||
success: true,
|
||||
is_healthy,
|
||||
|
||||
@@ -3,4 +3,5 @@ use jobs_common::job_stats::JobStats;
|
||||
#[derive(Clone)]
|
||||
pub struct HttpServerSharedState {
|
||||
pub job_stats: JobStats,
|
||||
pub consecutive_failure_unhealthy_threshold: u64,
|
||||
}
|
||||
@@ -27,6 +27,8 @@ pub fn run_http_server(args: CreateServerArgs) -> AnyhowResult<Server>
|
||||
|
||||
let server_state = HttpServerSharedState {
|
||||
job_stats: args.job_stats.clone(),
|
||||
consecutive_failure_unhealthy_threshold:
|
||||
easyenv::get_env_num("CONSECUTIVE_FAILURE_UNHEALTHY_THRESHOLD", 3)?,
|
||||
};
|
||||
|
||||
let server_state_arc = web::Data::new(Arc::new(server_state));
|
||||
|
||||
Reference in new issue
Block a user