use of org.apache.camel.impl.cloud.DefaultServiceHealth in project camel by apache.
the class ConsulServiceDiscovery method newService.
private ServiceDefinition newService(String serviceName, CatalogService service, List<ServiceHealth> serviceHealthList) {
Map<String, String> meta = new HashMap<>();
ObjectHelper.ifNotEmpty(service.getServiceId(), val -> meta.put("service_id", val));
ObjectHelper.ifNotEmpty(service.getNode(), val -> meta.put("node", val));
ObjectHelper.ifNotEmpty(service.getServiceName(), val -> meta.put("service_name", val));
List<String> tags = service.getServiceTags();
if (tags != null) {
for (String tag : service.getServiceTags()) {
String[] items = tag.split("=");
if (items.length == 1) {
meta.put(items[0], items[0]);
} else if (items.length == 2) {
meta.put(items[0], items[1]);
}
}
}
return new DefaultServiceDefinition(serviceName, service.getServiceAddress(), service.getServicePort(), meta, new DefaultServiceHealth(serviceHealthList.stream().allMatch(this::isHealthy)));
}
Aggregations