1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

Polish alibaba/spring-cloud-alibaba/#1196 : [Issue] NacosConfigHealthIndicator should not be UP in any status

This commit is contained in:
mercyblitz 2020-02-04 18:42:55 +08:00
parent 4106d48810
commit 74ef969a33

View File

@ -20,9 +20,13 @@ import com.alibaba.nacos.api.config.ConfigService;
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
/**
* The {@link HealthIndicator} for Nacos Config
*
* @author xiaojing
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
public class NacosConfigHealthIndicator extends AbstractHealthIndicator {
@ -34,10 +38,21 @@ public class NacosConfigHealthIndicator extends AbstractHealthIndicator {
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
builder.up();
// Just return "UP" or "DOWN"
String status = configService.getServerStatus();
// Set the status to Builder
builder.status(status);
switch (status) {
case "UP":
builder.up();
break;
case "DOWN":
builder.down();
break;
default:
builder.unknown();
break;
}
}
}