mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 22:08:17 +08:00
removed tasks we dont need
This commit is contained in:
@ -2,10 +2,9 @@
|
||||
{
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Responses;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public interface ILoadBalancerFactory
|
||||
{
|
||||
Task<Response<ILoadBalancer>> Get(DownstreamReRoute reRoute, ServiceProviderConfiguration config);
|
||||
Response<ILoadBalancer> Get(DownstreamReRoute reRoute, ServiceProviderConfiguration config);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
using Ocelot.Configuration;
|
||||
using Ocelot.Responses;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ocelot.LoadBalancer.LoadBalancers
|
||||
{
|
||||
public interface ILoadBalancerHouse
|
||||
{
|
||||
Task<Response<ILoadBalancer>> Get(DownstreamReRoute reRoute, ServiceProviderConfiguration config);
|
||||
Response<ILoadBalancer> Get(DownstreamReRoute reRoute, ServiceProviderConfiguration config);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
_loadBalancerCreators = loadBalancerCreators;
|
||||
}
|
||||
|
||||
public Task<Response<ILoadBalancer>> Get(DownstreamReRoute reRoute, ServiceProviderConfiguration config)
|
||||
public Response<ILoadBalancer> Get(DownstreamReRoute reRoute, ServiceProviderConfiguration config)
|
||||
{
|
||||
var serviceProviderFactoryResponse = _serviceProviderFactory.Get(config, reRoute);
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
response = new OkResponse<ILoadBalancer>(createdLoadBalancer);
|
||||
}
|
||||
|
||||
return Task.FromResult(response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ using Ocelot.Responses;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ocelot.LoadBalancer.LoadBalancers
|
||||
{
|
||||
@ -18,7 +17,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
||||
_loadBalancers = new ConcurrentDictionary<string, ILoadBalancer>();
|
||||
}
|
||||
|
||||
public async Task<Response<ILoadBalancer>> Get(DownstreamReRoute reRoute, ServiceProviderConfiguration config)
|
||||
public Response<ILoadBalancer> Get(DownstreamReRoute reRoute, ServiceProviderConfiguration config)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -30,7 +29,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
||||
|
||||
if (reRoute.LoadBalancerOptions.Type != loadBalancer.GetType().Name)
|
||||
{
|
||||
result = await _factory.Get(reRoute, config);
|
||||
result = _factory.Get(reRoute, config);
|
||||
if (result.IsError)
|
||||
{
|
||||
return new ErrorResponse<ILoadBalancer>(result.Errors);
|
||||
@ -43,7 +42,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
||||
return new OkResponse<ILoadBalancer>(loadBalancer);
|
||||
}
|
||||
|
||||
result = await _factory.Get(reRoute, config);
|
||||
result = _factory.Get(reRoute, config);
|
||||
|
||||
if (result.IsError)
|
||||
{
|
||||
@ -58,7 +57,7 @@ namespace Ocelot.LoadBalancer.LoadBalancers
|
||||
{
|
||||
return new ErrorResponse<ILoadBalancer>(new List<Ocelot.Errors.Error>()
|
||||
{
|
||||
new UnableToFindLoadBalancerError($"unabe to find load balancer for {reRoute.LoadBalancerKey} exception is {ex}")
|
||||
new UnableToFindLoadBalancerError($"unabe to find load balancer for {reRoute.LoadBalancerKey} exception is {ex}"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace Ocelot.LoadBalancer.Middleware
|
||||
|
||||
public async Task Invoke(DownstreamContext context)
|
||||
{
|
||||
var loadBalancer = await _loadBalancerHouse.Get(context.DownstreamReRoute, context.Configuration.ServiceProviderConfiguration);
|
||||
var loadBalancer = _loadBalancerHouse.Get(context.DownstreamReRoute, context.Configuration.ServiceProviderConfiguration);
|
||||
if (loadBalancer.IsError)
|
||||
{
|
||||
Logger.LogDebug("there was an error retriving the loadbalancer, setting pipeline error");
|
||||
|
Reference in New Issue
Block a user