mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 15:50:49 +08:00 
			
		
		
		
	merge circuitbreakerpattern code
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
				
			|||||||
 {
 | 
					 {
 | 
				
			||||||
  "projects": [ "src", "test" ],
 | 
					  "projects": [ "src", "test" ],
 | 
				
			||||||
    "sdk": {
 | 
					    "sdk": {
 | 
				
			||||||
        "version": "1.0.0-preview2-003133"
 | 
					        "version": "1.0.0-preview2-003131"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -248,7 +248,8 @@ namespace Ocelot.Configuration.Builder
 | 
				
			|||||||
                _isAuthenticated, new AuthenticationOptions(_authenticationProvider, _authenticationProviderUrl, _scopeName, 
 | 
					                _isAuthenticated, new AuthenticationOptions(_authenticationProvider, _authenticationProviderUrl, _scopeName, 
 | 
				
			||||||
                _requireHttps, _additionalScopes, _scopeSecret), _configHeaderExtractorProperties, _claimToClaims, _routeClaimRequirement, 
 | 
					                _requireHttps, _additionalScopes, _scopeSecret), _configHeaderExtractorProperties, _claimToClaims, _routeClaimRequirement, 
 | 
				
			||||||
                _isAuthorised, _claimToQueries, _requestIdHeaderKey, _isCached, _fileCacheOptions, _downstreamScheme, _loadBalancer,
 | 
					                _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);
 | 
					                 _exceptionsAllowedBeforeBreaking,_durationOfBreak, _timeoutValue);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -103,9 +103,6 @@ namespace Ocelot.Configuration.Creator
 | 
				
			|||||||
            var useServiceDiscovery = !string.IsNullOrEmpty(fileReRoute.ServiceName)
 | 
					            var useServiceDiscovery = !string.IsNullOrEmpty(fileReRoute.ServiceName)
 | 
				
			||||||
                && !string.IsNullOrEmpty(globalConfiguration?.ServiceDiscoveryProvider?.Provider);
 | 
					                && !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
 | 
					             //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}";
 | 
					            var loadBalancerKey = $"{fileReRoute.UpstreamTemplate}{fileReRoute.UpstreamHttpMethod}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -130,16 +127,16 @@ namespace Ocelot.Configuration.Creator
 | 
				
			|||||||
                var claimsToClaims = GetAddThingsToRequest(fileReRoute.AddClaimsToRequest);
 | 
					                var claimsToClaims = GetAddThingsToRequest(fileReRoute.AddClaimsToRequest);
 | 
				
			||||||
                var claimsToQueries = GetAddThingsToRequest(fileReRoute.AddQueriesToRequest);
 | 
					                var claimsToQueries = GetAddThingsToRequest(fileReRoute.AddQueriesToRequest);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
               reRoute = new ReRoute(new DownstreamPathTemplate(fileReRoute.DownstreamPathTemplate),
 | 
					                reRoute = new ReRoute(new DownstreamPathTemplate(fileReRoute.DownstreamPathTemplate),
 | 
				
			||||||
                    fileReRoute.UpstreamTemplate,
 | 
					                   fileReRoute.UpstreamTemplate,
 | 
				
			||||||
                    fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated,
 | 
					                   fileReRoute.UpstreamHttpMethod, upstreamTemplate, isAuthenticated,
 | 
				
			||||||
                    authOptionsForRoute, claimsToHeaders, claimsToClaims,
 | 
					                   authOptionsForRoute, claimsToHeaders, claimsToClaims,
 | 
				
			||||||
                    fileReRoute.RouteClaimsRequirement, isAuthorised, claimsToQueries,
 | 
					                   fileReRoute.RouteClaimsRequirement, isAuthorised, claimsToQueries,
 | 
				
			||||||
                    requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds)
 | 
					                   requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds)
 | 
				
			||||||
                    , fileReRoute.DownstreamScheme,
 | 
					                   , fileReRoute.DownstreamScheme,
 | 
				
			||||||
                    fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey,
 | 
					                   fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey,
 | 
				
			||||||
                    serviceProviderConfiguration, serviceProviderConfiguration ,reRoute.ExceptionsAllowedBeforeBreaking,
 | 
					                   serviceProviderConfiguration, fileReRoute.ExceptionsAllowedBeforeBreaking,
 | 
				
			||||||
                    reRoute.DurationOfBreak, reRoute.TimeoutValue);
 | 
					                    fileReRoute.DurationOfBreak, fileReRoute.TimeoutValue);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@@ -151,8 +148,8 @@ namespace Ocelot.Configuration.Creator
 | 
				
			|||||||
                    requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds),
 | 
					                    requestIdKey, isCached, new CacheOptions(fileReRoute.FileCacheOptions.TtlSeconds),
 | 
				
			||||||
                    fileReRoute.DownstreamScheme,
 | 
					                    fileReRoute.DownstreamScheme,
 | 
				
			||||||
                    fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey,
 | 
					                    fileReRoute.LoadBalancer, fileReRoute.DownstreamHost, fileReRoute.DownstreamPort, loadBalancerKey,
 | 
				
			||||||
                    serviceProviderConfiguration, serviceProviderConfiguration ,reRoute.ExceptionsAllowedBeforeBreaking,
 | 
					                    serviceProviderConfiguration, fileReRoute.ExceptionsAllowedBeforeBreaking,
 | 
				
			||||||
                    reRoute.DurationOfBreak, reRoute.TimeoutValue);
 | 
					                    fileReRoute.DurationOfBreak, fileReRoute.TimeoutValue);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
            var loadBalancer = await _loadBalanceFactory.Get(reRoute);
 | 
					            var loadBalancer = await _loadBalanceFactory.Get(reRoute);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ namespace Ocelot.Configuration
 | 
				
			|||||||
            List<ClaimToThing> claimsToQueries, 
 | 
					            List<ClaimToThing> claimsToQueries, 
 | 
				
			||||||
            string requestIdKey, bool isCached, CacheOptions fileCacheOptions, 
 | 
					            string requestIdKey, bool isCached, CacheOptions fileCacheOptions, 
 | 
				
			||||||
            string downstreamScheme, string loadBalancer, string downstreamHost, 
 | 
					            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)
 | 
					            int exceptionsAllowedBeforeBreaking =3, int durationofBreak =8, int timeoutValue = 5000)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            LoadBalancerKey = loadBalancerKey;
 | 
					            LoadBalancerKey = loadBalancerKey;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,38 +1,38 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "version": "0.0.0-dev",
 | 
					  "version": "0.0.0-dev",
 | 
				
			||||||
    "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
        "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
 | 
				
			||||||
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
 | 
					    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
 | 
				
			||||||
        "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
 | 
					    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
 | 
				
			||||||
        "Microsoft.Extensions.Configuration.Json": "1.1.0",
 | 
					    "Microsoft.Extensions.Configuration.Json": "1.1.0",
 | 
				
			||||||
        "Microsoft.Extensions.Logging": "1.1.0",
 | 
					    "Microsoft.Extensions.Logging": "1.1.0",
 | 
				
			||||||
        "Microsoft.Extensions.Logging.Console": "1.1.0",
 | 
					    "Microsoft.Extensions.Logging.Console": "1.1.0",
 | 
				
			||||||
        "Microsoft.Extensions.Logging.Debug": "1.1.0",
 | 
					    "Microsoft.Extensions.Logging.Debug": "1.1.0",
 | 
				
			||||||
        "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
 | 
					    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Http": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Http": "1.1.0",
 | 
				
			||||||
        "System.Text.RegularExpressions": "4.3.0",
 | 
					    "System.Text.RegularExpressions": "4.3.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Authentication.OAuth": "1.1.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Authentication.Google": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Authentication.Google": "1.1.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Authentication.Facebook": "1.1.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Authentication.Twitter": "1.1.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Authentication.MicrosoftAccount": "1.1.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Authentication": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Authentication": "1.1.0",
 | 
				
			||||||
        "IdentityServer4.AccessTokenValidation": "1.0.2",
 | 
					    "IdentityServer4.AccessTokenValidation": "1.0.2",
 | 
				
			||||||
        "Microsoft.AspNetCore.Mvc": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Mvc": "1.1.0",
 | 
				
			||||||
        "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
 | 
					    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
 | 
				
			||||||
        "Microsoft.NETCore.App": "1.1.0",
 | 
					    "Microsoft.NETCore.App": "1.1.0",
 | 
				
			||||||
        "CacheManager.Core": "0.9.2",
 | 
					    "CacheManager.Core": "0.9.2",
 | 
				
			||||||
        "CacheManager.Microsoft.Extensions.Configuration": "0.9.2",
 | 
					    "CacheManager.Microsoft.Extensions.Configuration": "0.9.2",
 | 
				
			||||||
        "CacheManager.Microsoft.Extensions.Logging": "0.9.2",
 | 
					    "CacheManager.Microsoft.Extensions.Logging": "0.9.2",
 | 
				
			||||||
        "Consul": "0.7.2.1",
 | 
					    "Consul": "0.7.2.1",
 | 
				
			||||||
         "Polly": "5.0.3"
 | 
					    "Polly": "5.0.3"
 | 
				
			||||||
   },
 | 
					  },
 | 
				
			||||||
  "runtimes": {
 | 
					  "runtimes": {
 | 
				
			||||||
    "win10-x64": {},
 | 
					    "win10-x64": {},
 | 
				
			||||||
    "osx.10.11-x64":{},
 | 
					    "osx.10.11-x64": {},
 | 
				
			||||||
    "win7-x64": {}
 | 
					    "win7-x64": {}
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "frameworks": {
 | 
					  "frameworks": {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
{"ReRoutes":[{"DownstreamPathTemplate":"41879/","UpstreamTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ScopeName":null,"RequireHttps":false,"AdditionalScopes":[],"ScopeSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"http","DownstreamHost":"localhost","DownstreamPort":41879,"LoadBalancer":null, ,"ExceptionsAllowedBeforeBreaking":3,"DurationOfBreak":5,"TimeoutValue":5000}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":null,"Host":null,"Port":0}}}
 | 
					{"ReRoutes":[{"DownstreamPathTemplate":"41879/","UpstreamTemplate":"/","UpstreamHttpMethod":"Get","AuthenticationOptions":{"Provider":null,"ProviderRootUrl":null,"ScopeName":null,"RequireHttps":false,"AdditionalScopes":[],"ScopeSecret":null},"AddHeadersToRequest":{},"AddClaimsToRequest":{},"RouteClaimsRequirement":{},"AddQueriesToRequest":{},"RequestIdKey":null,"FileCacheOptions":{"TtlSeconds":0},"ReRouteIsCaseSensitive":false,"ServiceName":null,"DownstreamScheme":"http","DownstreamHost":"localhost","DownstreamPort":41879,"ExceptionsAllowedBeforeBreaking":3,"DurationOfBreak":5,"TimeoutValue":5000,"LoadBalancer":null}],"GlobalConfiguration":{"RequestIdKey":null,"ServiceDiscoveryProvider":{"Provider":null,"Host":null,"Port":0}}}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user