예제 #1
0
 public ProxyConfigLoader(
     ILogger <ProxyConfigLoader> logger,
     IClustersRepo clustersRepo,
     IRoutesRepo routesRepo,
     IReverseProxyConfigManager proxyManager,
     IOptionsMonitor <ProxyConfigOptions> proxyConfig)
 {
     _logger        = logger ?? throw new ArgumentNullException(nameof(logger));
     _clustersRepo  = clustersRepo ?? throw new ArgumentNullException(nameof(clustersRepo));
     _routesRepo    = routesRepo ?? throw new ArgumentNullException(nameof(routesRepo));
     _proxyManager  = proxyManager ?? throw new ArgumentNullException(nameof(proxyManager));
     _proxyConfig   = proxyConfig ?? throw new ArgumentNullException(nameof(proxyConfig));
     _errorReporter = new LoggerConfigErrorReporter(_logger);
 }
예제 #2
0
        private async Task ApplyAsync(ProxyConfigOptions config)
        {
            if (config == null)
            {
                return;
            }

            Log.ApplyProxyConfig(_logger);
            try
            {
                await _backendsRepo.SetBackendsAsync(config.Backends, CancellationToken.None);

                await _routesRepo.SetRoutesAsync(config.Routes, CancellationToken.None);

                var errorReporter = new LoggerConfigErrorReporter(_logger);
                await _proxyManager.ApplyConfigurationsAsync(errorReporter, CancellationToken.None);
            }
            catch (Exception ex)
            {
                Log.ApplyProxyConfigFailed(_logger, ex.Message, ex);
            }
        }
예제 #3
0
        private async Task ApplyAsync(ProxyConfigOptions config)
        {
            if (config == null)
            {
                return;
            }

            _logger.LogInformation("Applying proxy configs");
            try
            {
                await _backendsRepo.SetBackendsAsync(config.Backends, CancellationToken.None);

                await _routesRepo.SetRoutesAsync(config.Routes, CancellationToken.None);

                var errorReporter = new LoggerConfigErrorReporter(_logger);
                await _proxyManager.ApplyConfigurationsAsync(errorReporter, CancellationToken.None);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, $"Failed to apply new configs: {ex.Message}");
            }
        }