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