mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	getting acceptance tests working again
This commit is contained in:
		@@ -168,6 +168,8 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
                .WithEnableRateLimiting(fileReRouteOptions.EnableRateLimiting)
 | 
			
		||||
                .WithRateLimitOptions(rateLimitOption)
 | 
			
		||||
                .WithHttpHandlerOptions(httpHandlerOptions)
 | 
			
		||||
                .WithServiceName(fileReRoute.ServiceName)
 | 
			
		||||
                .WithUseServiceDiscovery(fileReRoute.UseServiceDiscovery)
 | 
			
		||||
                .Build();
 | 
			
		||||
 | 
			
		||||
            SetupQosProvider(reRoute);
 | 
			
		||||
 
 | 
			
		||||
@@ -37,5 +37,6 @@ namespace Ocelot.Configuration.File
 | 
			
		||||
        public FileRateLimitRule RateLimitOptions { get; set; }
 | 
			
		||||
        public FileAuthenticationOptions AuthenticationOptions { get; set; }
 | 
			
		||||
        public FileHttpHandlerOptions HttpHandlerOptions { get; set; }
 | 
			
		||||
        public bool UseServiceDiscovery {get;set;}
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +1,5 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Concurrent;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Ocelot.Configuration;
 | 
			
		||||
@@ -9,12 +10,12 @@ namespace Ocelot.LoadBalancer.LoadBalancers
 | 
			
		||||
    public class LoadBalancerHouse : ILoadBalancerHouse
 | 
			
		||||
    {
 | 
			
		||||
        private readonly ILoadBalancerFactory _factory;
 | 
			
		||||
        private readonly Dictionary<string, ILoadBalancer> _loadBalancers;
 | 
			
		||||
        private readonly ConcurrentDictionary<string, ILoadBalancer> _loadBalancers;
 | 
			
		||||
 | 
			
		||||
        public LoadBalancerHouse(ILoadBalancerFactory factory)
 | 
			
		||||
        {
 | 
			
		||||
            _factory = factory;
 | 
			
		||||
            _loadBalancers = new Dictionary<string, ILoadBalancer>();
 | 
			
		||||
            _loadBalancers = new ConcurrentDictionary<string, ILoadBalancer>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public async Task<Response<ILoadBalancer>> Get(ReRoute reRoute, ServiceProviderConfiguration config)
 | 
			
		||||
@@ -54,13 +55,18 @@ namespace Ocelot.LoadBalancer.LoadBalancers
 | 
			
		||||
 | 
			
		||||
        private void AddLoadBalancer(string key, ILoadBalancer loadBalancer)
 | 
			
		||||
        {
 | 
			
		||||
            if (!_loadBalancers.ContainsKey(key))
 | 
			
		||||
            {
 | 
			
		||||
                _loadBalancers.Add(key, loadBalancer);
 | 
			
		||||
            }
 | 
			
		||||
            _loadBalancers.AddOrUpdate(key, loadBalancer, (x, y) => {
 | 
			
		||||
                return loadBalancer;
 | 
			
		||||
            });
 | 
			
		||||
            
 | 
			
		||||
            // if (!_loadBalancers.ContainsKey(key))
 | 
			
		||||
            // {
 | 
			
		||||
            //     _loadBalancers.TryAdd(key, loadBalancer);
 | 
			
		||||
            // }
 | 
			
		||||
 | 
			
		||||
            _loadBalancers.Remove(key);
 | 
			
		||||
            _loadBalancers.Add(key, loadBalancer);
 | 
			
		||||
            // ILoadBalancer old;
 | 
			
		||||
            // _loadBalancers.Remove(key, out old);
 | 
			
		||||
            // _loadBalancers.TryAdd(key, loadBalancer);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user