mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 14:10:50 +08:00 
			
		
		
		
	hacked together load balancing reroutes in fileconfig (#211)
* hacked together load balancing reroutes in fileconfig * some renaming and refactoring * more renames * hacked away the old config json * test for issue 213 * renamed key * dont share ports * oops * updated docs * mvoed docs around * port being used
This commit is contained in:
		@@ -1,24 +1,24 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
			
		||||
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <VersionPrefix>0.0.0-dev</VersionPrefix>
 | 
			
		||||
    <TargetFramework>netcoreapp2.0</TargetFramework>
 | 
			
		||||
    <RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
 | 
			
		||||
    <AssemblyName>Ocelot.Benchmarks</AssemblyName>
 | 
			
		||||
    <OutputType>Exe</OutputType>
 | 
			
		||||
    <PackageId>Ocelot.Benchmarks</PackageId>
 | 
			
		||||
    <RuntimeIdentifiers>osx.10.11-x64;osx.10.12-x64;win7-x64;win10-x64</RuntimeIdentifiers>
 | 
			
		||||
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
 | 
			
		||||
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
 | 
			
		||||
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="BenchmarkDotNet" Version="0.10.9" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
</Project>
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk">
 | 
			
		||||
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <VersionPrefix>0.0.0-dev</VersionPrefix>
 | 
			
		||||
    <TargetFramework>netcoreapp2.0</TargetFramework>
 | 
			
		||||
    <RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
 | 
			
		||||
    <AssemblyName>Ocelot.Benchmarks</AssemblyName>
 | 
			
		||||
    <OutputType>Exe</OutputType>
 | 
			
		||||
    <PackageId>Ocelot.Benchmarks</PackageId>
 | 
			
		||||
    <RuntimeIdentifiers>osx.10.11-x64;osx.10.12-x64;win7-x64;win10-x64</RuntimeIdentifiers>
 | 
			
		||||
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
 | 
			
		||||
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
 | 
			
		||||
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <ProjectReference Include="..\..\src\Ocelot\Ocelot.csproj" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="BenchmarkDotNet" Version="0.10.9" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
</Project>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,17 +1,17 @@
 | 
			
		||||
using BenchmarkDotNet.Running;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Benchmarks
 | 
			
		||||
{
 | 
			
		||||
    public class Program
 | 
			
		||||
    {
 | 
			
		||||
        public static void Main(string[] args)
 | 
			
		||||
        {
 | 
			
		||||
            var switcher = new BenchmarkSwitcher(new[] {
 | 
			
		||||
                   typeof(UrlPathToUrlPathTemplateMatcherBenchmarks),
 | 
			
		||||
 | 
			
		||||
               });
 | 
			
		||||
 | 
			
		||||
            switcher.Run(args);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
using BenchmarkDotNet.Running;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Benchmarks
 | 
			
		||||
{
 | 
			
		||||
    public class Program
 | 
			
		||||
    {
 | 
			
		||||
        public static void Main(string[] args)
 | 
			
		||||
        {
 | 
			
		||||
            var switcher = new BenchmarkSwitcher(new[] {
 | 
			
		||||
                   typeof(UrlPathToUrlPathTemplateMatcherBenchmarks),
 | 
			
		||||
 | 
			
		||||
               });
 | 
			
		||||
 | 
			
		||||
            switcher.Run(args);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,19 +1,19 @@
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using System.Runtime.CompilerServices;
 | 
			
		||||
using System.Runtime.InteropServices;
 | 
			
		||||
 | 
			
		||||
// General Information about an assembly is controlled through the following
 | 
			
		||||
// set of attributes. Change these attribute values to modify the information
 | 
			
		||||
// associated with an assembly.
 | 
			
		||||
[assembly: AssemblyConfiguration("")]
 | 
			
		||||
[assembly: AssemblyCompany("")]
 | 
			
		||||
[assembly: AssemblyProduct("Ocelot.Benchmarks")]
 | 
			
		||||
[assembly: AssemblyTrademark("")]
 | 
			
		||||
 | 
			
		||||
// Setting ComVisible to false makes the types in this assembly not visible
 | 
			
		||||
// to COM components.  If you need to access a type in this assembly from
 | 
			
		||||
// COM, set the ComVisible attribute to true on that type.
 | 
			
		||||
[assembly: ComVisible(false)]
 | 
			
		||||
 | 
			
		||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
 | 
			
		||||
[assembly: Guid("106b49e6-95f6-4a7b-b81c-96bfa74af035")]
 | 
			
		||||
using System.Reflection;
 | 
			
		||||
using System.Runtime.CompilerServices;
 | 
			
		||||
using System.Runtime.InteropServices;
 | 
			
		||||
 | 
			
		||||
// General Information about an assembly is controlled through the following
 | 
			
		||||
// set of attributes. Change these attribute values to modify the information
 | 
			
		||||
// associated with an assembly.
 | 
			
		||||
[assembly: AssemblyConfiguration("")]
 | 
			
		||||
[assembly: AssemblyCompany("")]
 | 
			
		||||
[assembly: AssemblyProduct("Ocelot.Benchmarks")]
 | 
			
		||||
[assembly: AssemblyTrademark("")]
 | 
			
		||||
 | 
			
		||||
// Setting ComVisible to false makes the types in this assembly not visible
 | 
			
		||||
// to COM components.  If you need to access a type in this assembly from
 | 
			
		||||
// COM, set the ComVisible attribute to true on that type.
 | 
			
		||||
[assembly: ComVisible(false)]
 | 
			
		||||
 | 
			
		||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
 | 
			
		||||
[assembly: Guid("106b49e6-95f6-4a7b-b81c-96bfa74af035")]
 | 
			
		||||
 
 | 
			
		||||
@@ -1,40 +1,40 @@
 | 
			
		||||
using BenchmarkDotNet.Attributes;
 | 
			
		||||
using BenchmarkDotNet.Columns;
 | 
			
		||||
using BenchmarkDotNet.Configs;
 | 
			
		||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Benchmarks
 | 
			
		||||
{
 | 
			
		||||
    [Config(typeof(UrlPathToUrlPathTemplateMatcherBenchmarks))]
 | 
			
		||||
    public class UrlPathToUrlPathTemplateMatcherBenchmarks : ManualConfig
 | 
			
		||||
    {
 | 
			
		||||
        private RegExUrlMatcher _urlPathMatcher;
 | 
			
		||||
        private string _downstreamUrlPath;
 | 
			
		||||
        private string _downstreamUrlPathTemplate;
 | 
			
		||||
 | 
			
		||||
        public UrlPathToUrlPathTemplateMatcherBenchmarks()
 | 
			
		||||
        {
 | 
			
		||||
            Add(StatisticColumn.AllStatistics);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Setup]
 | 
			
		||||
        public void SetUp()
 | 
			
		||||
        {
 | 
			
		||||
            _urlPathMatcher = new RegExUrlMatcher();
 | 
			
		||||
            _downstreamUrlPath = "api/product/products/1/variants/?soldout=false";
 | 
			
		||||
            _downstreamUrlPathTemplate = "api/product/products/{productId}/variants/";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Benchmark]
 | 
			
		||||
        public void Benchmark1()
 | 
			
		||||
        {
 | 
			
		||||
            _urlPathMatcher.Match(_downstreamUrlPath, _downstreamUrlPathTemplate);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Benchmark]
 | 
			
		||||
        public void Benchmark2()
 | 
			
		||||
        {
 | 
			
		||||
            _urlPathMatcher.Match(_downstreamUrlPath, _downstreamUrlPathTemplate);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
using BenchmarkDotNet.Attributes;
 | 
			
		||||
using BenchmarkDotNet.Columns;
 | 
			
		||||
using BenchmarkDotNet.Configs;
 | 
			
		||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.Benchmarks
 | 
			
		||||
{
 | 
			
		||||
    [Config(typeof(UrlPathToUrlPathTemplateMatcherBenchmarks))]
 | 
			
		||||
    public class UrlPathToUrlPathTemplateMatcherBenchmarks : ManualConfig
 | 
			
		||||
    {
 | 
			
		||||
        private RegExUrlMatcher _urlPathMatcher;
 | 
			
		||||
        private string _downstreamUrlPath;
 | 
			
		||||
        private string _downstreamUrlPathTemplate;
 | 
			
		||||
 | 
			
		||||
        public UrlPathToUrlPathTemplateMatcherBenchmarks()
 | 
			
		||||
        {
 | 
			
		||||
            Add(StatisticColumn.AllStatistics);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Setup]
 | 
			
		||||
        public void SetUp()
 | 
			
		||||
        {
 | 
			
		||||
            _urlPathMatcher = new RegExUrlMatcher();
 | 
			
		||||
            _downstreamUrlPath = "api/product/products/1/variants/?soldout=false";
 | 
			
		||||
            _downstreamUrlPathTemplate = "api/product/products/{productId}/variants/";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Benchmark]
 | 
			
		||||
        public void Benchmark1()
 | 
			
		||||
        {
 | 
			
		||||
            _urlPathMatcher.Match(_downstreamUrlPath, _downstreamUrlPathTemplate);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Benchmark]
 | 
			
		||||
        public void Benchmark2()
 | 
			
		||||
        {
 | 
			
		||||
            _urlPathMatcher.Match(_downstreamUrlPath, _downstreamUrlPathTemplate);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user