Commit 95aaa41d authored by sunshanpeng's avatar sunshanpeng Committed by Jared Tan

refactor:health check can be simpler (#2642)

parent 437026f3
...@@ -17,17 +17,13 @@ public class AdminServiceHealthIndicator implements HealthIndicator { ...@@ -17,17 +17,13 @@ public class AdminServiceHealthIndicator implements HealthIndicator {
@Override @Override
public Health health() { public Health health() {
int errorCode = check(); check();
if (errorCode != 0) {
return Health.down().withDetail("Error Code", errorCode).build();
}
return Health.up().build(); return Health.up().build();
} }
private int check() { private void check() {
PageRequest pageable = PageRequest.of(0, 1); PageRequest pageable = PageRequest.of(0, 1);
appService.findAll(pageable); appService.findAll(pageable);
return 0;
} }
} }
...@@ -17,17 +17,13 @@ public class ConfigServiceHealthIndicator implements HealthIndicator { ...@@ -17,17 +17,13 @@ public class ConfigServiceHealthIndicator implements HealthIndicator {
@Override @Override
public Health health() { public Health health() {
int errorCode = check(); check();
if (errorCode != 0) {
return Health.down().withDetail("Error Code", errorCode).build();
}
return Health.up().build(); return Health.up().build();
} }
private int check() { private void check() {
PageRequest pageable = PageRequest.of(0, 1); PageRequest pageable = PageRequest.of(0, 1);
appService.findAll(pageable); appService.findAll(pageable);
return 0;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment