mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-09-18 10:42:42 +08:00
wip tests failing
This commit is contained in:
@@ -1,35 +1,35 @@
|
||||
namespace Ocelot.Provider.Eureka
|
||||
{
|
||||
using ServiceDiscovery.Providers;
|
||||
using Steeltoe.Common.Discovery;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Values;
|
||||
|
||||
public class Eureka : IServiceDiscoveryProvider
|
||||
{
|
||||
private readonly IDiscoveryClient _client;
|
||||
private readonly string _serviceName;
|
||||
|
||||
public Eureka(string serviceName, IDiscoveryClient client)
|
||||
{
|
||||
_client = client;
|
||||
_serviceName = serviceName;
|
||||
}
|
||||
|
||||
public Task<List<Service>> Get()
|
||||
{
|
||||
var services = new List<Service>();
|
||||
|
||||
var instances = _client.GetInstances(_serviceName);
|
||||
|
||||
if (instances != null && instances.Any())
|
||||
{
|
||||
services.AddRange(instances.Select(i => new Service(i.ServiceId, new ServiceHostAndPort(i.Host, i.Port, i.Uri.Scheme), "", "", new List<string>())));
|
||||
}
|
||||
|
||||
return Task.FromResult(services);
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace Ocelot.Provider.Eureka
|
||||
{
|
||||
using Ocelot.ServiceDiscovery.Providers;
|
||||
using Steeltoe.Discovery;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ocelot.Values;
|
||||
|
||||
public class Eureka : IServiceDiscoveryProvider
|
||||
{
|
||||
private readonly IDiscoveryClient _client;
|
||||
private readonly string _serviceName;
|
||||
|
||||
public Eureka(string serviceName, IDiscoveryClient client)
|
||||
{
|
||||
_client = client;
|
||||
_serviceName = serviceName;
|
||||
}
|
||||
|
||||
public Task<List<Service>> Get()
|
||||
{
|
||||
var services = new List<Service>();
|
||||
|
||||
var instances = _client.GetInstances(_serviceName);
|
||||
|
||||
if (instances != null && instances.Any())
|
||||
{
|
||||
services.AddRange(instances.Select(i => new Service(i.ServiceId, new ServiceHostAndPort(i.Host, i.Port, i.Uri.Scheme), "", "", new List<string>())));
|
||||
}
|
||||
|
||||
return Task.FromResult(services);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
namespace Ocelot.Provider.Eureka
|
||||
{
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ServiceDiscovery;
|
||||
using Steeltoe.Common.Discovery;
|
||||
|
||||
using Ocelot.ServiceDiscovery;
|
||||
using Steeltoe.Discovery;
|
||||
|
||||
public static class EurekaProviderFactory
|
||||
{
|
||||
public static ServiceDiscoveryFinderDelegate Get = (provider, config, route) =>
|
||||
|
@@ -27,7 +27,7 @@
|
||||
<ProjectReference Include="..\Ocelot\Ocelot.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="2.4.2" />
|
||||
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="3.0.1" />
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
Reference in New Issue
Block a user