class ConsulConfigSourceProvider implements ConfigSourceProvider {

    @Override
    public Iterable<ConfigSource> getConfigSources(ClassLoader cl) {
        Map<String, ValueType> keys = config.keysAsMap();
        if (keys.isEmpty()) {
            log.debug("No keys were configured for config source lookup");
            return Collections.emptyList();
        }

        List<ConfigSource> result = new ArrayList<>(keys.size());

        for (Map.Entry<String, ValueType> entry : keys.entrySet()) {
            String fullKey = config.prefix.isPresent() ? config.prefix.get() + "/" + entry.getKey() : entry.getKey();
            log.debug("Attempting to look up value of key '" + fullKey + "' from Consul.");

            try {
                Optional<Response> optionalResponse = consulConfigGateway.getValue(fullKey);
                if (optionalResponse.isPresent()) {
                    result.add(
                            responseConfigSourceUtil.toConfigSource(optionalResponse.get(), entry.getValue(), config.prefix));
                } else {
                    String message = "Key '" + fullKey + "' not found in Consul.";
                    if (config.failOnMissingKey) {
                        throw new RuntimeException(message);
                    } else {
                        log.info(message);
                    }
                }
                log.debug("Done reading value of key '" + fullKey + "'");
            } catch (IOException e) {
                throw new UncheckedIOException("An error occurred while attempting to fetch configuration from Consul.", e);
            }
        }

        return result;
    }

    public  ConsulConfigSourceProvider(ConsulConfig config);
      ConsulConfigSourceProvider(ConsulConfig config, ConsulConfigGateway consulConfigGateway);
    private  ConsulConfigSourceProvider(ConsulConfig config, ConsulConfigGateway consulConfigGateway,
            ResponseConfigSourceUtil responseConfigSourceUtil);

}