Solon

solon.health

<dependency>
    <groupId>org.noear</groupId>
    <artifactId>solon.health</artifactId>
</dependency>

1、描述

基础扩展插件,为 Solon Web 或服务提供公共的健康检测支持。

2、使用示例

添加几个检测指标

@Configuration
public class Config {
    @Bean
    public void initHealthCheckPoint() {
        //test...
        HealthChecker.addIndicator("preflight", Result::succeed);
        HealthChecker.addIndicator("test", Result::failure);
        HealthChecker.addIndicator("boom", () -> {
            throw new IllegalStateException();
        });
    }
}

检测效果

GET /healthz
Response Code:
200 : Everything is fine
503 : At least one procedure has reported a non-healthy state
500 : One procedure has thrown an error or has not reported a status in time
Response:
{"status":"ERROR","details":{"test":{"status":"DOWN"},"boom":{"status":"ERROR"},"preflight":{"status":"UP","details":{"total":987656789,"free":6783,"threshold":7989031}}}}