mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	merge circuitbreakerpattern code
This commit is contained in:
		@@ -248,7 +248,8 @@ namespace Ocelot.Configuration.Builder
 | 
			
		||||
                _isAuthenticated, new AuthenticationOptions(_authenticationProvider, _authenticationProviderUrl, _scopeName, 
 | 
			
		||||
                _requireHttps, _additionalScopes, _scopeSecret), _configHeaderExtractorProperties, _claimToClaims, _routeClaimRequirement, 
 | 
			
		||||
                _isAuthorised, _claimToQueries, _requestIdHeaderKey, _isCached, _fileCacheOptions, _downstreamScheme, _loadBalancer,
 | 
			
		||||
                _downstreamHost, _dsPort, _loadBalancerKey, new ServiceProviderConfiguraion(_serviceName, _downstreamHost, _dsPort, _useServiceDiscovery, _serviceDiscoveryProvider, _serviceProviderHost, _serviceProviderPort),
 | 
			
		||||
                _downstreamHost, _dsPort, _loadBalancerKey, new ServiceProviderConfiguraion(_serviceName, _downstreamHost, _dsPort, _useServiceDiscovery,
 | 
			
		||||
                _serviceDiscoveryProvider, _serviceProviderHost, _serviceProviderPort),
 | 
			
		||||
                 _exceptionsAllowedBeforeBreaking,_durationOfBreak, _timeoutValue);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -103,9 +103,6 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
            var useServiceDiscovery = !string.IsNullOrEmpty(fileReRoute.ServiceName)
 | 
			
		||||
                && !string.IsNullOrEmpty(globalConfiguration?.ServiceDiscoveryProvider?.Provider);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            Func<HostAndPort> downstreamHostAndPortFunc = () => new HostAndPort(reRoute.DownstreamHost.Trim('/'), reRoute.DownstreamPort);
 | 
			
		||||
 | 
			
		||||
             //note - not sure if this is the correct key, but this is probably the only unique key i can think of given my poor brain
 | 
			
		||||
            var loadBalancerKey = $"{fileReRoute.UpstreamTemplate}{fileReRoute.UpstreamHttpMethod}";
 | 
			
		||||
 | 
			
		||||
@@ -130,16 +127,16 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
                var claimsToClaims = GetAddThingsToRequest(fileReRoute.AddClaimsToRequest);
 | 
			
		||||
                var claimsToQueries = GetAddThingsToRequest(fileReRoute.AddQueriesToRequest);
 | 
			
		||||
 | 
			
		||||
               reRoute = new ReRoute(new DownstreamPathTemplate(fileReRoute.DownstreamPathTemplate),
 | 
			
		||||
                    fileReRoute.UpstreamTemplate,
 | 
			
		||||
                    fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated,
 | 
			
		||||
                    authOptionsForRoute, claimsToHeaders, claimsToClaims,
 | 
			
		||||
                    fileReRoute.RouteClaimsRequirement, isAuthorised, claimsToQueries,
 | 
			
		||||
                    requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds)
 | 
			
		||||
                    , fileReRoute.DownstreamScheme,
 | 
			
		||||
                    fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey,
 | 
			
		||||
                    serviceProviderConfiguration, serviceProviderConfiguration ,reRoute.ExceptionsAllowedBeforeBreaking,
 | 
			
		||||
                    reRoute.DurationOfBreak, reRoute.TimeoutValue);
 | 
			
		||||
                reRoute = new ReRoute(new DownstreamPathTemplate(fileReRoute.DownstreamPathTemplate),
 | 
			
		||||
                   fileReRoute.UpstreamTemplate,
 | 
			
		||||
                   fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated,
 | 
			
		||||
                   authOptionsForRoute, claimsToHeaders, claimsToClaims,
 | 
			
		||||
                   fileReRoute.RouteClaimsRequirement, isAuthorised, claimsToQueries,
 | 
			
		||||
                   requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds)
 | 
			
		||||
                   , fileReRoute.DownstreamScheme,
 | 
			
		||||
                   fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey,
 | 
			
		||||
                   serviceProviderConfiguration, fileReRoute.ExceptionsAllowedBeforeBreaking,
 | 
			
		||||
                    fileReRoute.DurationOfBreak, fileReRoute.TimeoutValue);
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@@ -151,10 +148,10 @@ namespace Ocelot.Configuration.Creator
 | 
			
		||||
                    requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds),
 | 
			
		||||
                    fileReRoute.DownstreamScheme,
 | 
			
		||||
                    fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey,
 | 
			
		||||
                    serviceProviderConfiguration, serviceProviderConfiguration ,reRoute.ExceptionsAllowedBeforeBreaking,
 | 
			
		||||
                    reRoute.DurationOfBreak, reRoute.TimeoutValue);
 | 
			
		||||
                    serviceProviderConfiguration, fileReRoute.ExceptionsAllowedBeforeBreaking,
 | 
			
		||||
                    fileReRoute.DurationOfBreak, fileReRoute.TimeoutValue);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
      
 | 
			
		||||
            var loadBalancer = await _loadBalanceFactory.Get(reRoute);
 | 
			
		||||
            _loadBalancerHouse.Add(reRoute.LoadBalancerKey, loadBalancer);
 | 
			
		||||
            return reRoute;
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ namespace Ocelot.Configuration
 | 
			
		||||
            List<ClaimToThing> claimsToQueries, 
 | 
			
		||||
            string requestIdKey, bool isCached, CacheOptions fileCacheOptions, 
 | 
			
		||||
            string downstreamScheme, string loadBalancer, string downstreamHost, 
 | 
			
		||||
            int downstreamPort, string loadBalancerKey, ServiceProviderConfiguraion serviceProviderConfiguraion,
 | 
			
		||||
            int downstreamPort, string loadBalancerKey, ServiceProviderConfiguraion serviceProviderConfiguraion,
 | 
			
		||||
            int exceptionsAllowedBeforeBreaking =3, int durationofBreak =8, int timeoutValue = 5000)
 | 
			
		||||
        {
 | 
			
		||||
            LoadBalancerKey = loadBalancerKey;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,38 +1,38 @@
 | 
			
		||||
{
 | 
			
		||||
  "version": "0.0.0-dev",
 | 
			
		||||
    "dependencies": {
 | 
			
		||||
        "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
 | 
			
		||||
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
 | 
			
		||||
        "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
 | 
			
		||||
        "Microsoft.Extensions.Configuration.Json": "1.1.0",
 | 
			
		||||
        "Microsoft.Extensions.Logging": "1.1.0",
 | 
			
		||||
        "Microsoft.Extensions.Logging.Console": "1.1.0",
 | 
			
		||||
        "Microsoft.Extensions.Logging.Debug": "1.1.0",
 | 
			
		||||
        "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Http": "1.1.0",
 | 
			
		||||
        "System.Text.RegularExpressions": "4.3.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Authentication.Google": "1.1.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Authentication": "1.1.0",
 | 
			
		||||
        "IdentityServer4.AccessTokenValidation": "1.0.2",
 | 
			
		||||
        "Microsoft.AspNetCore.Mvc": "1.1.0",
 | 
			
		||||
        "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
 | 
			
		||||
        "Microsoft.NETCore.App": "1.1.0",
 | 
			
		||||
        "CacheManager.Core": "0.9.2",
 | 
			
		||||
        "CacheManager.Microsoft.Extensions.Configuration": "0.9.2",
 | 
			
		||||
        "CacheManager.Microsoft.Extensions.Logging": "0.9.2",
 | 
			
		||||
        "Consul": "0.7.2.1",
 | 
			
		||||
         "Polly": "5.0.3"
 | 
			
		||||
   },
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
 | 
			
		||||
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
 | 
			
		||||
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
 | 
			
		||||
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
 | 
			
		||||
    "Microsoft.Extensions.Logging": "1.1.0",
 | 
			
		||||
    "Microsoft.Extensions.Logging.Console": "1.1.0",
 | 
			
		||||
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
 | 
			
		||||
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Http": "1.1.0",
 | 
			
		||||
    "System.Text.RegularExpressions": "4.3.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Authentication.Google": "1.1.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Authentication": "1.1.0",
 | 
			
		||||
    "IdentityServer4.AccessTokenValidation": "1.0.2",
 | 
			
		||||
    "Microsoft.AspNetCore.Mvc": "1.1.0",
 | 
			
		||||
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
 | 
			
		||||
    "Microsoft.NETCore.App": "1.1.0",
 | 
			
		||||
    "CacheManager.Core": "0.9.2",
 | 
			
		||||
    "CacheManager.Microsoft.Extensions.Configuration": "0.9.2",
 | 
			
		||||
    "CacheManager.Microsoft.Extensions.Logging": "0.9.2",
 | 
			
		||||
    "Consul": "0.7.2.1",
 | 
			
		||||
    "Polly": "5.0.3"
 | 
			
		||||
  },
 | 
			
		||||
  "runtimes": {
 | 
			
		||||
    "win10-x64": {},
 | 
			
		||||
    "osx.10.11-x64":{},
 | 
			
		||||
    "osx.10.11-x64": {},
 | 
			
		||||
    "win7-x64": {}
 | 
			
		||||
  },
 | 
			
		||||
  "frameworks": {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user