internal ConfigEnvironment LoadInternal(bool updateDictionary = true)
        {
            // Refresh settings with latest configuration values
            ConfigurationSettingsHelper.Initialize(PREFIX, _settings, _configuration);

            if (!_settings.Enabled)
            {
                _logger?.LogInformation("Config Server client disabled, did not fetch configuration!");
                return(null);
            }

            if (IsDiscoveryFirstEnabled())
            {
                var discoveryService = new ConfigServerDiscoveryService(_configuration, _settings, _loggerFactory);
                DiscoverServerInstances(discoveryService);
            }

            // Adds client settings (e.g spring:cloud:config:uri, etc) to the Data dictionary
            AddConfigServerClientSettings();

            if (_settings.RetryEnabled && _settings.FailFast)
            {
                var attempts = 0;
                var backOff  = _settings.RetryInitialInterval;
                do
                {
                    _logger?.LogInformation("Fetching config from server at: {0}", _settings.Uri);
                    try
                    {
                        return(DoLoad(updateDictionary));
                    }
                    catch (ConfigServerException e)
                    {
                        _logger?.LogInformation("Failed fetching config from server at: {0}, Exception: {1}", _settings.Uri, e);
                        attempts++;
                        if (attempts < _settings.RetryAttempts)
                        {
                            Thread.CurrentThread.Join(backOff);
                            var nextBackoff = (int)(backOff * _settings.RetryMultiplier);
                            backOff = Math.Min(nextBackoff, _settings.RetryMaxInterval);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }while (true);
            }
            else
            {
                _logger?.LogInformation("Fetching config from server at: {0}", _settings.Uri);
                return(DoLoad(updateDictionary));
            }
        }
        internal void DiscoverServerInstances(ConfigServerDiscoveryService discoveryService)
        {
            IList <IServiceInstance> instances = discoveryService.GetConfigServerInstances();

            if (instances == null || instances.Count == 0)
            {
                if (_settings.FailFast)
                {
                    throw new ConfigServerException("Could not locate config server via discovery, are you missing a Discovery service assembly?");
                }

                return;
            }

            UpdateSettingsFromDiscovery(instances, _settings);
        }