Feature/#574 look at httpclient cache key (#589)

* #574 consolidate some code, man the config stuff is a mess!

* #574 just use the downstream re route and the key for caching http clients

* #574 added benchmark, i was suprised to learn using a complex type was faster than a string in benchmark .net dictionary tests, hey ho probably dont have enough data in the type...
This commit is contained in:
Tom Pallister
2018-09-01 13:10:45 +01:00
committed by GitHub
parent 55277cac45
commit 66b68fc685
40 changed files with 672 additions and 289 deletions

View File

@ -5,11 +5,8 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
using Moq;
using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.DownstreamRouteFinder;
using Ocelot.DownstreamRouteFinder.Finder;
using Ocelot.DownstreamRouteFinder.UrlMatcher;
using Ocelot.Responses;
using Ocelot.Values;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
@ -30,8 +27,8 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
services.AddSingleton<IPlaceholderNameAndValueFinder, UrlPathPlaceholderNameAndValueFinder>();
services.AddSingleton<IUrlPathToUrlTemplateMatcher, RegExUrlMatcher>();
services.AddSingleton<IQoSOptionsCreator, QoSOptionsCreator>();
services.AddSingleton<IDownstreamRouteProvider, Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteFinder>();
services.AddSingleton<IDownstreamRouteProvider, Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteCreator>();
services.AddSingleton<IDownstreamRouteProvider, DownstreamRouteFinder>();
services.AddSingleton<IDownstreamRouteProvider, DownstreamRouteCreator>();
var provider = services.BuildServiceProvider();
_logger = new Mock<IOcelotLogger>();
_loggerFactory = new Mock<IOcelotLoggerFactory>();
@ -49,7 +46,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
this.Given(_ => GivenTheReRoutes(reRoutes))
.When(_ => WhenIGet())
.Then(_ => ThenTheResultShouldBe<Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteFinder>())
.Then(_ => ThenTheResultShouldBe<DownstreamRouteFinder>())
.BDDfy();
}
@ -59,12 +56,12 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
var spConfig = new ServiceProviderConfigurationBuilder().WithHost("test").WithPort(50).WithType("test").Build();
var reRoutes = new List<ReRoute>
{
new ReRouteBuilder().WithUpstreamPathTemplate("woot").Build()
new ReRouteBuilder().WithUpstreamTemplatePattern(new UpstreamPathTemplateBuilder().WithOriginalValue("woot").Build()).Build()
};
this.Given(_ => GivenTheReRoutes(reRoutes, spConfig))
.When(_ => WhenIGet())
.Then(_ => ThenTheResultShouldBe<Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteFinder>())
.Then(_ => ThenTheResultShouldBe<DownstreamRouteFinder>())
.BDDfy();
}
@ -76,7 +73,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
this.Given(_ => GivenTheReRoutes(reRoutes, spConfig))
.When(_ => WhenIGet())
.Then(_ => ThenTheResultShouldBe<Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteFinder>())
.Then(_ => ThenTheResultShouldBe<DownstreamRouteFinder>())
.BDDfy();
}
@ -88,7 +85,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
this.Given(_ => GivenTheReRoutes(reRoutes, spConfig))
.When(_ => WhenIGet())
.Then(_ => ThenTheResultShouldBe<Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteFinder>())
.Then(_ => ThenTheResultShouldBe<DownstreamRouteFinder>())
.BDDfy();
}
@ -100,7 +97,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
this.Given(_ => GivenTheReRoutes(reRoutes, spConfig))
.When(_ => WhenIGet())
.Then(_ => ThenTheResultShouldBe<Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteFinder>())
.Then(_ => ThenTheResultShouldBe<DownstreamRouteFinder>())
.BDDfy();
}
@ -112,7 +109,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
this.Given(_ => GivenTheReRoutes(reRoutes, spConfig))
.When(_ => WhenIGet())
.Then(_ => ThenTheResultShouldBe<Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteCreator>())
.Then(_ => ThenTheResultShouldBe<DownstreamRouteCreator>())
.BDDfy();
}
@ -127,7 +124,7 @@ namespace Ocelot.UnitTests.DownstreamRouteFinder
this.Given(_ => GivenTheReRoutes(reRoutes, spConfig))
.When(_ => WhenIGet())
.Then(_ => ThenTheResultShouldBe<Ocelot.DownstreamRouteFinder.Finder.DownstreamRouteCreator>())
.Then(_ => ThenTheResultShouldBe<DownstreamRouteCreator>())
.BDDfy();
}