fix(proxy): reset health badges when proxy stops

Clear all provider_health records when stopping the proxy server,
ensuring health badges reset to "healthy" state. This fixes the
inconsistency where circuit breakers (in memory) would reset on
stop but health badges (in database) would retain stale state.
This commit is contained in:
Jason
2025-12-15 22:52:58 +08:00
parent 007813e09e
commit e081c7560c
2 changed files with 17 additions and 0 deletions
+11
View File
@@ -230,6 +230,17 @@ impl Database {
Ok(())
}
/// 清空所有Provider健康状态(代理停止时调用)
pub async fn clear_all_provider_health(&self) -> Result<(), AppError> {
let conn = lock_conn!(self.conn);
conn.execute("DELETE FROM provider_health", [])
.map_err(|e| AppError::Database(e.to_string()))?;
log::debug!("Cleared all provider health records");
Ok(())
}
// ==================== Circuit Breaker Config ====================
/// 获取熔断器配置