diff --git a/src/Ocelot.Provider.Consul/ConsulServiceDiscoveryProvider.cs b/src/Ocelot.Provider.Consul/Consul.cs similarity index 89% rename from src/Ocelot.Provider.Consul/ConsulServiceDiscoveryProvider.cs rename to src/Ocelot.Provider.Consul/Consul.cs index fd5558a..b202cd5 100644 --- a/src/Ocelot.Provider.Consul/ConsulServiceDiscoveryProvider.cs +++ b/src/Ocelot.Provider.Consul/Consul.cs @@ -10,16 +10,17 @@ using ServiceDiscovery.Providers; using Values; - public class ConsulServiceDiscoveryProvider : IServiceDiscoveryProvider + + public class Consul : IServiceDiscoveryProvider { private readonly ConsulRegistryConfiguration _config; private readonly IOcelotLogger _logger; private readonly IConsulClient _consul; private const string VersionPrefix = "version-"; - public ConsulServiceDiscoveryProvider(ConsulRegistryConfiguration config, IOcelotLoggerFactory factory, IConsulClientFactory clientFactory) + public Consul(ConsulRegistryConfiguration config, IOcelotLoggerFactory factory, IConsulClientFactory clientFactory) { - _logger = factory.CreateLogger(); + _logger = factory.CreateLogger(); _config = config; _consul = clientFactory.Get(_config); } diff --git a/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs b/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs index ccf84cb..5309540 100644 --- a/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs +++ b/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs @@ -16,11 +16,11 @@ public static class ConsulProviderFactory var consulRegistryConfiguration = new ConsulRegistryConfiguration(config.Host, config.Port, name, config.Token); - var consulServiceDiscoveryProvider = new ConsulServiceDiscoveryProvider(consulRegistryConfiguration, factory, consulFactory); + var consulServiceDiscoveryProvider = new Consul(consulRegistryConfiguration, factory, consulFactory); if (config.Type?.ToLower() == "pollconsul") { - return new PollingConsulServiceDiscoveryProvider(config.PollingInterval, factory, consulServiceDiscoveryProvider); + return new PollConsul(config.PollingInterval, factory, consulServiceDiscoveryProvider); } return consulServiceDiscoveryProvider; diff --git a/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs b/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs index f2a6e8f..3247015 100644 --- a/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs +++ b/src/Ocelot.Provider.Consul/PollingConsulServiceDiscoveryProvider.cs @@ -7,7 +7,7 @@ using ServiceDiscovery.Providers; using Values; - public class PollingConsulServiceDiscoveryProvider : IServiceDiscoveryProvider + public class PollConsul : IServiceDiscoveryProvider { private readonly IOcelotLogger _logger; private readonly IServiceDiscoveryProvider _consulServiceDiscoveryProvider; @@ -15,9 +15,9 @@ public class PollingConsulServiceDiscoveryProvider : IServiceDiscoveryProvider private bool _polling; private List _services; - public PollingConsulServiceDiscoveryProvider(int pollingInterval, IOcelotLoggerFactory factory, IServiceDiscoveryProvider consulServiceDiscoveryProvider) + public PollConsul(int pollingInterval, IOcelotLoggerFactory factory, IServiceDiscoveryProvider consulServiceDiscoveryProvider) { - _logger = factory.CreateLogger(); + _logger = factory.CreateLogger(); _consulServiceDiscoveryProvider = consulServiceDiscoveryProvider; _services = new List(); diff --git a/test/Ocelot.Provider.Consul.UnitTests/ConsulServiceDiscoveryProviderTests.cs b/test/Ocelot.Provider.Consul.UnitTests/ConsulServiceDiscoveryProviderTests.cs index 0a52950..03e0837 100644 --- a/test/Ocelot.Provider.Consul.UnitTests/ConsulServiceDiscoveryProviderTests.cs +++ b/test/Ocelot.Provider.Consul.UnitTests/ConsulServiceDiscoveryProviderTests.cs @@ -19,7 +19,7 @@ public class ConsulServiceDiscoveryProviderTests : IDisposable { private IWebHost _fakeConsulBuilder; private readonly List _serviceEntries; - private ConsulServiceDiscoveryProvider _provider; + private Consul _provider; private readonly string _serviceName; private readonly int _port; private readonly string _consulHost; @@ -40,10 +40,10 @@ public ConsulServiceDiscoveryProviderTests() _factory = new Mock(); _clientFactory = new ConsulClientFactory(); _logger = new Mock(); - _factory.Setup(x => x.CreateLogger()).Returns(_logger.Object); - _factory.Setup(x => x.CreateLogger()).Returns(_logger.Object); + _factory.Setup(x => x.CreateLogger()).Returns(_logger.Object); + _factory.Setup(x => x.CreateLogger()).Returns(_logger.Object); var config = new ConsulRegistryConfiguration(_consulHost, _port, _serviceName, null); - _provider = new ConsulServiceDiscoveryProvider(config, _factory.Object, _clientFactory); + _provider = new Consul(config, _factory.Object, _clientFactory); } [Fact] @@ -73,7 +73,7 @@ public void should_use_token() { var token = "test token"; var config = new ConsulRegistryConfiguration(_consulHost, _port, _serviceName, token); - _provider = new ConsulServiceDiscoveryProvider(config, _factory.Object, _clientFactory); + _provider = new Consul(config, _factory.Object, _clientFactory); var serviceEntryOne = new ServiceEntry() { diff --git a/test/Ocelot.Provider.Consul.UnitTests/PollingConsulServiceDiscoveryProviderTests.cs b/test/Ocelot.Provider.Consul.UnitTests/PollingConsulServiceDiscoveryProviderTests.cs index 284a987..34948cb 100644 --- a/test/Ocelot.Provider.Consul.UnitTests/PollingConsulServiceDiscoveryProviderTests.cs +++ b/test/Ocelot.Provider.Consul.UnitTests/PollingConsulServiceDiscoveryProviderTests.cs @@ -14,7 +14,7 @@ public class PollingConsulServiceDiscoveryProviderTests { private readonly int _delay; - private PollingConsulServiceDiscoveryProvider _provider; + private PollConsul _provider; private readonly List _services; private readonly Mock _factory; private readonly Mock _logger; @@ -27,7 +27,7 @@ public PollingConsulServiceDiscoveryProviderTests() _delay = 1; _factory = new Mock(); _logger = new Mock(); - _factory.Setup(x => x.CreateLogger()).Returns(_logger.Object); + _factory.Setup(x => x.CreateLogger()).Returns(_logger.Object); _consulServiceDiscoveryProvider = new Mock(); } @@ -55,7 +55,7 @@ private void ThenTheCountIs(int count) private void WhenIGetTheServices(int expected) { - _provider = new PollingConsulServiceDiscoveryProvider(_delay, _factory.Object, _consulServiceDiscoveryProvider.Object); + _provider = new PollConsul(_delay, _factory.Object, _consulServiceDiscoveryProvider.Object); var result = Wait.WaitFor(3000).Until(() => { try diff --git a/test/Ocelot.Provider.Consul.UnitTests/ProviderFactoryTests.cs b/test/Ocelot.Provider.Consul.UnitTests/ProviderFactoryTests.cs index 67d1837..fca7492 100644 --- a/test/Ocelot.Provider.Consul.UnitTests/ProviderFactoryTests.cs +++ b/test/Ocelot.Provider.Consul.UnitTests/ProviderFactoryTests.cs @@ -17,8 +17,8 @@ public ProviderFactoryTests() var services = new ServiceCollection(); var loggerFactory = new Mock(); var logger = new Mock(); - loggerFactory.Setup(x => x.CreateLogger()).Returns(logger.Object); - loggerFactory.Setup(x => x.CreateLogger()).Returns(logger.Object); + loggerFactory.Setup(x => x.CreateLogger()).Returns(logger.Object); + loggerFactory.Setup(x => x.CreateLogger()).Returns(logger.Object); var consulFactory = new Mock(); services.AddSingleton(consulFactory.Object); services.AddSingleton(loggerFactory.Object); @@ -29,7 +29,7 @@ public ProviderFactoryTests() public void should_return_ConsulServiceDiscoveryProvider() { var provider = ConsulProviderFactory.Get(_provider, new ServiceProviderConfiguration("", "", 1, "", "", 1), ""); - provider.ShouldBeOfType(); + provider.ShouldBeOfType(); } [Fact] @@ -37,7 +37,7 @@ public void should_return_PollingConsulServiceDiscoveryProvider() { var stopsPollerFromPolling = 10000; var provider = ConsulProviderFactory.Get(_provider, new ServiceProviderConfiguration("pollconsul", "", 1, "", "", stopsPollerFromPolling), ""); - provider.ShouldBeOfType(); + provider.ShouldBeOfType(); } } }