internal void DoLoad() { Exception error = null; try { foreach (string label in GetLabels()) { // Make Config Server URI from settings var path = GetConfigServerUri(label); // Invoke config server, and wait for results Task <ConfigEnvironment> task = RemoteLoadAsync(path); task.Wait(); ConfigEnvironment env = task.Result; // Update config Data dictionary with any results if (env != null) { _logger?.LogInformation("Located environment: {0}, {1}, {2}, {3}", env.Name, env.Profiles, env.Label, env.Version); var sources = env.PropertySources; if (sources != null) { int index = sources.Count - 1; for (; index >= 0; index--) { AddPropertySource(sources[index]); } } return; } } } catch (Exception e) { error = e; } _logger?.LogWarning("Could not locate PropertySource: " + error?.ToString()); if (_settings.FailFast) { throw new ConfigServerException("Could not locate PropertySource, fail fast property is set, failing", error); } }
internal ConfigEnvironment DoLoad(bool updateDictionary = true) { Exception error = null; // Get arrays of config server uris to check var uris = _settings.GetUris(); try { foreach (string label in GetLabels()) { Task <ConfigEnvironment> task = null; if (uris.Length > 1) { _logger?.LogInformation("Multiple Config Server Uris listed."); // Invoke config servers task = RemoteLoadAsync(uris, label); } else { // Single, server make Config Server URI from settings #pragma warning disable CS0618 // Type or member is obsolete var path = GetConfigServerUri(label); // Invoke config server task = RemoteLoadAsync(path); #pragma warning restore CS0618 // Type or member is obsolete } // Wait for results from server ConfigEnvironment env = task.GetAwaiter().GetResult(); // Update config Data dictionary with any results if (env != null) { _logger?.LogInformation( "Located environment: {name}, {profiles}, {label}, {version}, {state}", env.Name, env.Profiles, env.Label, env.Version, env.State); if (updateDictionary) { if (!string.IsNullOrEmpty(env.State)) { Data["spring:cloud:config:client:state"] = env.State; } if (!string.IsNullOrEmpty(env.Version)) { Data["spring:cloud:config:client:version"] = env.Version; } var sources = env.PropertySources; if (sources != null) { int index = sources.Count - 1; for (; index >= 0; index--) { AddPropertySource(sources[index]); } } } return(env); } } } catch (Exception e) { error = e; } _logger?.LogWarning("Could not locate PropertySource: " + error?.ToString()); if (_settings.FailFast) { throw new ConfigServerException("Could not locate PropertySource, fail fast property is set, failing", error); } return(null); }