CompletableFuture<List<Endpoint>> healthyEndpoints(String serviceName, @Nullable String datacenter,
                                                       @Nullable String filter) {
        requireNonNull(serviceName, "serviceName");
        final StringBuilder path = new StringBuilder("/health/service/");
        PercentEncoder.encodeComponent(path, serviceName);
        final QueryParamsBuilder paramsBuilder = QueryParams.builder();
        paramsBuilder.add(PASSING_PARAM, "true");
        paramsBuilder.add(ConsulClientUtil.queryParams(datacenter, filter));
        path.append('?').append(paramsBuilder.build().toQueryString());
        return client
                .get(path.toString())
                .aggregate()
                .handle((response, cause) -> {
                    if (cause != null) {
                        logger.warn("Unexpected exception while fetching the registry from Consul: {}" +
                                    " (serviceName: {})", client.uri(), serviceName, cause);
                        return null;
                    }

                    final HttpStatus status = response.status();
                    final String content = response.contentUtf8();
                    if (!status.isSuccess()) {
                        logger.warn("Unexpected response from Consul: {} (status: {}, content: {}," +
                                    " serviceName: {})", client.uri(), status, content, serviceName);
                        return null;
                    }

                    try {
                        return Arrays.stream(mapper.readValue(content, HealthService[].class))
                                     .map(HealthClient::toEndpoint)
                                     .filter(Objects::nonNull)
                                     .collect(toImmutableList());
                    } catch (IOException e) {
                        logger.warn("Unexpected exception while parsing a response from Consul: {}" +
                                    " (content: {}, serviceName: {})", client.uri(), content, serviceName, e);
                        return null;
                    }
                });
    }
Returns a healthy endpoint list by service name.
consul/src/main/java/com/linecorp/armeria/internal/consul/HealthClient.java