mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
revert
This commit is contained in:
parent
da0dd68502
commit
4c405f0f29
@ -19,7 +19,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
|||||||
private readonly Timer _timer;
|
private readonly Timer _timer;
|
||||||
private bool _expiring;
|
private bool _expiring;
|
||||||
|
|
||||||
public CookieStickySessions(ILoadBalancer loadBalancer, string key, int keyExpiryInMs, int expiryPeriodInMs)
|
public CookieStickySessions(ILoadBalancer loadBalancer, string key, int keyExpiryInMs)
|
||||||
{
|
{
|
||||||
_key = key;
|
_key = key;
|
||||||
_keyExpiryInMs = keyExpiryInMs;
|
_keyExpiryInMs = keyExpiryInMs;
|
||||||
@ -37,7 +37,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
|||||||
Expire();
|
Expire();
|
||||||
|
|
||||||
_expiring = false;
|
_expiring = false;
|
||||||
}, null, 0, expiryPeriodInMs);
|
}, null, 0, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -7,7 +7,6 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
|||||||
public class LoadBalancerFactory : ILoadBalancerFactory
|
public class LoadBalancerFactory : ILoadBalancerFactory
|
||||||
{
|
{
|
||||||
private readonly IServiceDiscoveryProviderFactory _serviceProviderFactory;
|
private readonly IServiceDiscoveryProviderFactory _serviceProviderFactory;
|
||||||
private const int ExpiryPeriodInMs = 50;
|
|
||||||
|
|
||||||
public LoadBalancerFactory(IServiceDiscoveryProviderFactory serviceProviderFactory)
|
public LoadBalancerFactory(IServiceDiscoveryProviderFactory serviceProviderFactory)
|
||||||
{
|
{
|
||||||
@ -26,7 +25,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
|||||||
return new LeastConnection(async () => await serviceProvider.Get(), reRoute.ServiceName);
|
return new LeastConnection(async () => await serviceProvider.Get(), reRoute.ServiceName);
|
||||||
case nameof(CookieStickySessions):
|
case nameof(CookieStickySessions):
|
||||||
var loadBalancer = new RoundRobin(async () => await serviceProvider.Get());
|
var loadBalancer = new RoundRobin(async () => await serviceProvider.Get());
|
||||||
return new CookieStickySessions(loadBalancer, reRoute.LoadBalancerOptions.Key, reRoute.LoadBalancerOptions.ExpiryInMs, ExpiryPeriodInMs);
|
return new CookieStickySessions(loadBalancer, reRoute.LoadBalancerOptions.Key, reRoute.LoadBalancerOptions.ExpiryInMs);
|
||||||
default:
|
default:
|
||||||
return new NoLoadBalancer(await serviceProvider.Get());
|
return new NoLoadBalancer(await serviceProvider.Get());
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
{
|
{
|
||||||
_loadBalancer = new Mock<ILoadBalancer>();
|
_loadBalancer = new Mock<ILoadBalancer>();
|
||||||
_defaultExpiryInMs = 100;
|
_defaultExpiryInMs = 100;
|
||||||
_stickySessions = new CookieStickySessions(_loadBalancer.Object, "sessionid", _defaultExpiryInMs, 1);
|
_stickySessions = new CookieStickySessions(_loadBalancer.Object, "sessionid", _defaultExpiryInMs);
|
||||||
_downstreamContext = new DownstreamContext(new DefaultHttpContext());
|
_downstreamContext = new DownstreamContext(new DefaultHttpContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,8 +73,6 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void should_expire_sticky_session()
|
public void should_expire_sticky_session()
|
||||||
{
|
{
|
||||||
_stickySessions = new CookieStickySessions(_loadBalancer.Object, "sessionid", _defaultExpiryInMs, 1);
|
|
||||||
|
|
||||||
this.Given(_ => GivenTheLoadBalancerReturnsSequence())
|
this.Given(_ => GivenTheLoadBalancerReturnsSequence())
|
||||||
.When(_ => WhenTheStickySessionExpires())
|
.When(_ => WhenTheStickySessionExpires())
|
||||||
.Then(_ => ThenANewHostAndPortIsReturned())
|
.Then(_ => ThenANewHostAndPortIsReturned())
|
||||||
@ -84,8 +82,6 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void should_refresh_sticky_session()
|
public void should_refresh_sticky_session()
|
||||||
{
|
{
|
||||||
_stickySessions = new CookieStickySessions(_loadBalancer.Object, "sessionid", _defaultExpiryInMs, 50);
|
|
||||||
|
|
||||||
this.Given(_ => GivenTheLoadBalancerReturnsSequence())
|
this.Given(_ => GivenTheLoadBalancerReturnsSequence())
|
||||||
.When(_ => WhenIMakeRequestsToKeepRefreshingTheSession())
|
.When(_ => WhenIMakeRequestsToKeepRefreshingTheSession())
|
||||||
.Then(_ => ThenTheSessionIsRefreshed())
|
.Then(_ => ThenTheSessionIsRefreshed())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user