private void UpdateSnapshot(ConfigurationOptions options) { // Prevent overlapping updates, especially on startup. lock (_lockObject) { Log.LoadData(_logger); var oldToken = _changeToken; _changeToken = new CancellationTokenSource(); _snapshot = new ConfigurationSnapshot() { Routes = options.Routes, Clusters = options.Clusters.Values.ToList(), ChangeToken = new CancellationChangeToken(_changeToken.Token) }; try { oldToken?.Cancel(throwOnFirstException: false); } catch (Exception ex) { Log.ErrorSignalingChange(_logger, ex); } } }
private void UpdateSnapshot() { // Prevent overlapping updates, especially on startup. lock (_lockObject) { Log.LoadData(_logger); ConfigurationSnapshot newSnapshot = null; try { newSnapshot = new ConfigurationSnapshot(); foreach (var section in _configuration.GetSection("Clusters").GetChildren()) { newSnapshot.Clusters.Add(CreateCluster(section)); } foreach (var section in _configuration.GetSection("Routes").GetChildren()) { newSnapshot.Routes.Add(CreateRoute(section)); } PurgeCertificateList(); } catch (Exception ex) { Log.ConfigurationDataConversionFailed(_logger, ex); // Re-throw on the first time load to prevent app from starting. if (_snapshot == null) { throw; } return; } var oldToken = _changeToken; _changeToken = new CancellationTokenSource(); newSnapshot.ChangeToken = new CancellationChangeToken(_changeToken.Token); _snapshot = newSnapshot; try { oldToken?.Cancel(throwOnFirstException: false); } catch (Exception ex) { Log.ErrorSignalingChange(_logger, ex); } } }
private void UpdateSnapshot(ConfigurationData data) { // Prevent overlapping updates, especially on startup. lock (_lockObject) { Log.LoadData(_logger); ConfigurationSnapshot newSnapshot = null; try { newSnapshot = new ConfigurationSnapshot() { Routes = data.Routes.Select(r => Convert(r)).ToList().AsReadOnly(), Clusters = data.Clusters.Select(c => Convert(c.Key, c.Value)).ToList().AsReadOnly() }; PurgeCertificateList(); } catch (Exception ex) { Log.ConfigurationDataConversionFailed(_logger, ex); // Re-throw on the first time load to prevent app from starting. if (_snapshot == null) { throw; } return; } var oldToken = _changeToken; _changeToken = new CancellationTokenSource(); newSnapshot.ChangeToken = new CancellationChangeToken(_changeToken.Token); _snapshot = newSnapshot; try { oldToken?.Cancel(throwOnFirstException: false); } catch (Exception ex) { Log.ErrorSignalingChange(_logger, ex); } } }