Remove Ocelot specific Middleware to make Ocelot more compatible with kestrel middleware and get ready for YARP

This commit is contained in:
Tom Pallister
2020-05-23 15:48:51 +01:00
committed by GitHub
parent 99a15d8668
commit fe3e8bd23a
214 changed files with 9574 additions and 9919 deletions

View File

@@ -1,31 +1,30 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Validators;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Configuration;
using Ocelot.DependencyInjection;
using Ocelot.DownstreamRouteFinder.Finder;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.Logging;
using Ocelot.Middleware;
using Ocelot.Middleware.Multiplexer;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Ocelot.Benchmarks
{
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Validators;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.Configuration;
using Ocelot.DependencyInjection;
using Ocelot.DownstreamRouteFinder.Finder;
using Ocelot.DownstreamRouteFinder.Middleware;
using Ocelot.Logging;
using Ocelot.Middleware;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
[SimpleJob(launchCount: 1, warmupCount: 2, targetCount: 5)]
[Config(typeof(DownstreamRouteFinderMiddlewareBenchmarks))]
public class DownstreamRouteFinderMiddlewareBenchmarks : ManualConfig
{
private DownstreamRouteFinderMiddleware _middleware;
private DownstreamContext _downstreamContext;
private OcelotRequestDelegate _next;
private RequestDelegate _next;
private HttpContext _httpContext;
public DownstreamRouteFinderMiddlewareBenchmarks()
{
@@ -43,7 +42,6 @@ namespace Ocelot.Benchmarks
var services = serviceCollection.BuildServiceProvider();
var loggerFactory = services.GetService<IOcelotLoggerFactory>();
var drpf = services.GetService<IDownstreamRouteProviderFactory>();
var multiplexer = services.GetService<IMultiplexer>();
_next = async context =>
{
@@ -51,22 +49,21 @@ namespace Ocelot.Benchmarks
throw new Exception("BOOM");
};
_middleware = new DownstreamRouteFinderMiddleware(_next, loggerFactory, drpf, multiplexer);
_middleware = new DownstreamRouteFinderMiddleware(_next, loggerFactory, drpf);
var httpContext = new DefaultHttpContext();
httpContext.Request.Path = new PathString("/test");
httpContext.Request.QueryString = new QueryString("?a=b");
httpContext.Request.Headers.Add("Host", "most");
httpContext.Items.SetIInternalConfiguration(new InternalConfiguration(new List<ReRoute>(), null, null, null, null, null, null, null, null));
_downstreamContext = new DownstreamContext(httpContext)
{
Configuration = new InternalConfiguration(new List<ReRoute>(), null, null, null, null, null, null, null, null)
};
_httpContext = httpContext;
}
[Benchmark(Baseline = true)]
public async Task Baseline()
{
await _middleware.Invoke(_downstreamContext);
await _middleware.Invoke(_httpContext);
}
}
}