Author noear,iYarnFog
- 🌈 一行代码添加检查点,侵入性极低。
- 📦 开箱即用的高质量组件。
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon.health</artifactId>
</dependency>
# No configuration.
@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}}}}