Class ChainHealthIndicator
java.lang.Object
tech.riemann.nif.starter.monitor.health.ChainHealthIndicator
- All Implemented Interfaces:
org.springframework.boot.health.contributor.HealthContributor, org.springframework.boot.health.contributor.HealthIndicator
public class ChainHealthIndicator
extends Object
implements org.springframework.boot.health.contributor.HealthIndicator
链式健康指示器,用于监控多个服务的健康状态
该类实现了 Spring Boot 的 HealthIndicator 接口,用于定期检查多个服务的健康状态 并将结果汇总为一个整体的健康状态
- Author:
- Kerbores(kerbores@riemann.tech)
-
Constructor Details
-
ChainHealthIndicator
public ChainHealthIndicator()
-
-
Method Details
-
init
@PostConstruct public void init()初始化方法,设置定时健康检查任务使用 @PostConstruct 注解,在 Bean 初始化时执行
-
destroy
@PreDestroy public void destroy()销毁方法,应用关闭时释放线程池资源,避免线程泄漏阻止 JVM 退出使用 @PreDestroy 注解,在 Bean 销毁时执行
-
healthCheckTask
public void healthCheckTask()执行健康检查任务该方法会并发检查所有服务的健康状态,并记录检查结果
-
health
public @NonNull org.springframework.boot.health.contributor.Health health()获取健康状态实现 HealthIndicator 接口的方法,返回整体的健康状态
- Specified by:
healthin interfaceorg.springframework.boot.health.contributor.HealthIndicator- Returns:
- 健康状态对象
-