Search in sources :

Example 6 with HealthService

use of com.ecwid.consul.v1.health.model.HealthService in project spring-cloud-consul by spring-cloud.

the class ConsulServerList method transformResponse.

/**
 * Transforms the response from Consul in to a list of usable {@link ConsulServer}s.
 *
 * @param healthServices the initial list of servers from Consul. Guaranteed to be non-empty list
 * @return ConsulServer instances
 * @see ConsulServer#ConsulServer(HealthService)
 */
protected List<ConsulServer> transformResponse(List<HealthService> healthServices) {
    List<ConsulServer> servers = new ArrayList<>();
    for (HealthService service : healthServices) {
        ConsulServer server = new ConsulServer(service);
        if (server.getMetadata().containsKey(this.properties.getDefaultZoneMetadataName())) {
            server.setZone(server.getMetadata().get(this.properties.getDefaultZoneMetadataName()));
        }
        servers.add(server);
    }
    return servers;
}
Also used : HealthService(com.ecwid.consul.v1.health.model.HealthService) ArrayList(java.util.ArrayList)

Aggregations

HealthService (com.ecwid.consul.v1.health.model.HealthService)6 ArrayList (java.util.ArrayList)4 ConsulService (com.weibo.api.motan.registry.consul.ConsulService)2 List (java.util.List)2 DefaultServiceInstance (org.springframework.cloud.client.DefaultServiceInstance)2 QueryParams (com.ecwid.consul.v1.QueryParams)1 NewService (com.ecwid.consul.v1.agent.model.NewService)1 Check (com.ecwid.consul.v1.health.model.Check)1 Service (com.ecwid.consul.v1.health.model.HealthService.Service)1 ServiceInstance (org.springframework.cloud.client.ServiceInstance)1