Skip to content

Commit

Permalink
Feature/remove pivotal (#541)
Browse files Browse the repository at this point in the history
* #529 removed eureka client

* #529 removed some unused code
  • Loading branch information
TomPallister authored Aug 12, 2018
1 parent 87348e5 commit 34afefc
Show file tree
Hide file tree
Showing 12 changed files with 5 additions and 568 deletions.
12 changes: 0 additions & 12 deletions src/Ocelot/DependencyInjection/OcelotBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ namespace Ocelot.DependencyInjection
using Ocelot.Infrastructure;
using Ocelot.Middleware.Multiplexer;
using ServiceDiscovery.Providers;
using Steeltoe.Common.Discovery;
using Pivotal.Discovery.Client;
using Ocelot.Request.Creator;

public class OcelotBuilder : IOcelotBuilder
Expand Down Expand Up @@ -109,16 +107,6 @@ public OcelotBuilder(IServiceCollection services, IConfiguration configurationRo
Services.TryAddSingleton<IHttpHandlerOptionsCreator, HttpHandlerOptionsCreator>();
Services.TryAddSingleton<IDownstreamAddressesCreator, DownstreamAddressesCreator>();
Services.TryAddSingleton<IDelegatingHandlerHandlerFactory, DelegatingHandlerHandlerFactory>();

if (UsingEurekaServiceDiscoveryProvider(configurationRoot))
{
Services.AddDiscoveryClient(configurationRoot);
}
else
{
Services.TryAddSingleton<IDiscoveryClient, FakeEurekaDiscoveryClient>();
}

Services.TryAddSingleton<IHttpRequester, HttpClientHttpRequester>();

// see this for why we register this as singleton http://stackoverflow.com/questions/37371264/invalidoperationexception-unable-to-resolve-service-for-type-microsoft-aspnetc
Expand Down
12 changes: 0 additions & 12 deletions src/Ocelot/Middleware/OcelotMiddlewareExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using Rafty.Concensus;
using Rafty.Infrastructure;
using Ocelot.Middleware.Pipeline;
using Pivotal.Discovery.Client;
using Rafty.Concensus.Node;
using Microsoft.Extensions.DependencyInjection;

Expand Down Expand Up @@ -48,15 +47,9 @@ public static async Task<IApplicationBuilder> UseOcelot(this IApplicationBuilder
SetUpRafty(builder);
}

if (UsingEurekaServiceDiscoveryProvider(configuration))
{
builder.UseDiscoveryClient();
}

ConfigureDiagnosticListener(builder);

return CreateOcelotPipeline(builder, pipelineConfiguration);

}

private static IApplicationBuilder CreateOcelotPipeline(IApplicationBuilder builder, OcelotPipelineConfiguration pipelineConfiguration)
Expand Down Expand Up @@ -84,11 +77,6 @@ rest of asp.net..
return builder;
}

private static bool UsingEurekaServiceDiscoveryProvider(IInternalConfiguration configuration)
{
return configuration?.ServiceProviderConfiguration != null && configuration.ServiceProviderConfiguration.Type?.ToLower() == "eureka";
}

private static bool UsingRafty(IApplicationBuilder builder)
{
var node = builder.ApplicationServices.GetService<INode>();
Expand Down
1 change: 0 additions & 1 deletion src/Ocelot/Ocelot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.0" />
<PackageReference Include="Polly" Version="6.0.1" />
<PackageReference Include="IdentityServer4" Version="2.2.0" />
<PackageReference Include="Pivotal.Discovery.ClientCore" Version="2.0.1" />
<PackageReference Include="Rafty" Version="0.4.4" />
</ItemGroup>
</Project>

This file was deleted.

27 changes: 0 additions & 27 deletions src/Ocelot/ServiceDiscovery/Providers/FakeEurekaDiscoveryClient.cs

This file was deleted.

10 changes: 1 addition & 9 deletions src/Ocelot/ServiceDiscovery/ServiceDiscoveryProviderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@ namespace Ocelot.ServiceDiscovery
using System;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Steeltoe.Common.Discovery;

public class ServiceDiscoveryProviderFactory : IServiceDiscoveryProviderFactory
{
private readonly IOcelotLoggerFactory _factory;
private readonly IDiscoveryClient _eurekaClient;
private readonly List<ServiceDiscoveryFinderDelegate> _delegates;
private readonly IServiceProvider _provider;

public ServiceDiscoveryProviderFactory(IOcelotLoggerFactory factory, IDiscoveryClient eurekaClient, IServiceProvider provider)
public ServiceDiscoveryProviderFactory(IOcelotLoggerFactory factory, IServiceProvider provider)
{
_factory = factory;
_eurekaClient = eurekaClient;
_provider = provider;
_delegates = provider
.GetServices<ServiceDiscoveryFinderDelegate>()
Expand Down Expand Up @@ -55,11 +52,6 @@ private IServiceDiscoveryProvider GetServiceDiscoveryProvider(ServiceProviderCon
return new ServiceFabricServiceDiscoveryProvider(sfConfig);
}

if (config.Type?.ToLower() == "eureka")
{
return new EurekaServiceDiscoveryProvider(key, _eurekaClient);
}

foreach (var serviceDiscoveryFinderDelegate in _delegates)
{
var provider = serviceDiscoveryFinderDelegate?.Invoke(_provider, config, key);
Expand Down
Loading

0 comments on commit 34afefc

Please sign in to comment.