org.zodiac.actuate.health.checker.ReadinessHealthCheckerProcessor Maven / Gradle / Ivy
The newest version!
package org.zodiac.actuate.health.checker;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthAggregator;
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
import java.util.List;
import java.util.Map;
public class ReadinessHealthCheckerProcessor extends AbstractHealthCheckerProcessor {
private List readinessHealthCheckers;
@SuppressWarnings("deprecation")
private HealthAggregator healthAggregator = new OrderedHealthAggregator();
public ReadinessHealthCheckerProcessor(HealthCheckerInfo healthCheckerInfo,
List readinessHealthCheckers) {
super(healthCheckerInfo);
this.readinessHealthCheckers = readinessHealthCheckers;
}
// @Override
// protected Health dohealthCheck() {
// if (readinessHealthCheckers == null || readinessHealthCheckers.isEmpty()) {
// return Health.up().build();
// }
// /*使用(key1, key2) -> key2)是避免key冲突,冲突时将前面的value 和后面的value拼接起来。*/
// Map healths = readinessHealthCheckers.stream().collect(
// Collectors.toMap(ReadinessHealthChecker::getName, ReadinessHealthChecker::isHealthy, (key1, key2) -> key2));
// return null != healths && healths.size() > 0 ? healthAggregator.aggregate(healths) : Health.up().build();
// }
@Override
protected Health afterHealthCheck(Map healths, boolean checkResult) {
return null != healths && healths.size() > 0 ? healthAggregator.aggregate(healths) : Health.up().build();
}
@Override
protected List getCheckers() {
return readinessHealthCheckers;
}
}