-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #262 - Integrated Steeltoe Service Discovery with Ocelot for review. * messing around * seems to be working with eureka * acceptance test passing with external lib references * #262 support for netflix eureka service discovery thanks to pivotal * #262 fixed warnings
- Loading branch information
1 parent
a5f3e0f
commit 4f061f2
Showing
18 changed files
with
665 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Ocelot/ServiceDiscovery/Providers/EurekaServiceDiscoveryProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace Ocelot.ServiceDiscovery.Providers | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Pivotal.Discovery.Client; | ||
using Values; | ||
|
||
public class EurekaServiceDiscoveryProvider : IServiceDiscoveryProvider | ||
{ | ||
private readonly IDiscoveryClient _client; | ||
private readonly string _serviceName; | ||
|
||
public EurekaServiceDiscoveryProvider(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), "", "", new List<string>()))); | ||
} | ||
|
||
return Task.FromResult(services); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Ocelot/ServiceDiscovery/Providers/FakeEurekaDiscoveryClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace Ocelot.ServiceDiscovery.Providers | ||
{ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Pivotal.Discovery.Client; | ||
|
||
public class FakeEurekaDiscoveryClient : IDiscoveryClient | ||
{ | ||
public IServiceInstance GetLocalServiceInstance() | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public IList<IServiceInstance> GetInstances(string serviceId) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public Task ShutdownAsync() | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public string Description { get; } | ||
public IList<string> Services { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.