use of com.netflix.appinfo.HealthCheckCallback in project chassis by Kixeye.
the class ChassisConfiguration method healthCheckRegistry.
/**
* Initializes the health check registry
*
* @return health check registry bean
*/
@Bean
public HealthCheckRegistry healthCheckRegistry(ApplicationContext context, DiscoveryManager eureka) {
final HealthCheckRegistry bean = new HealthCheckRegistry();
// auto-register beans implementing health checks
Map<String, HealthCheck> healthChecks = context.getBeansOfType(HealthCheck.class);
for (HealthCheck check : healthChecks.values()) {
bean.register(check.getClass().getName(), check);
}
// connect health checks into Eureka
if (!disableEureka) {
eureka.getDiscoveryClient().registerHealthCheckCallback(new HealthCheckCallback() {
@Override
public boolean isHealthy() {
for (Entry<String, HealthCheck.Result> entry : bean.runHealthChecks().entrySet()) {
if (!entry.getValue().isHealthy()) {
return false;
}
}
return true;
}
});
}
return bean;
}
Aggregations