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 Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    销毁方法,应用关闭时释放线程池资源,避免线程泄漏阻止 JVM 退出
    @NonNull org.springframework.boot.health.contributor.Health
    获取健康状态
    void
    执行健康检查任务
    void
    初始化方法,设置定时健康检查任务

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.boot.health.contributor.HealthIndicator

    health
  • 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:
      health in interface org.springframework.boot.health.contributor.HealthIndicator
      Returns:
      健康状态对象