Tom Pallister b74a1197a2
+semver: upgrade to net5.0 (#1390)
* breaking upgrade base build image to net5.0

* add make and build tools to image

* fix code broken after net5.0 upgrade

* fix warnings

* fix tests and line endings

* upgrade dotnet test and coverages packages

* update circle build image

* removed rafty and updated more packages

* bring back develop

* rename authorisation to authorization
2020-12-11 09:54:08 +00:00

36 lines
1.0 KiB
C#

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);
}
}
}