diff --git a/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs b/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs index 8eea73f25..7ac7612aa 100644 --- a/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs +++ b/src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs @@ -40,11 +40,17 @@ public async Task> Get() { var config = _cache.Get(_configurationKey, _configurationKey); - if (config != null) return new OkResponse(config); + if (config != null) + { + return new OkResponse(config); + } var queryResult = await _consul.KV.Get(_configurationKey); - if (queryResult.Response == null) return new OkResponse(null); + if (queryResult.Response == null) + { + return new OkResponse(null); + } var bytes = queryResult.Response.Value; @@ -63,7 +69,7 @@ public async Task Set(FileConfiguration ocelotConfiguration) var kvPair = new KVPair(_configurationKey) { - Value = bytes + Value = bytes, }; var result = await _consul.KV.Put(kvPair); diff --git a/src/Ocelot.Provider.Consul/ConsulMiddlewareConfigurationProvider.cs b/src/Ocelot.Provider.Consul/ConsulMiddlewareConfigurationProvider.cs index 924dd3dfe..f6b644199 100644 --- a/src/Ocelot.Provider.Consul/ConsulMiddlewareConfigurationProvider.cs +++ b/src/Ocelot.Provider.Consul/ConsulMiddlewareConfigurationProvider.cs @@ -19,7 +19,9 @@ public static class ConsulMiddlewareConfigurationProvider var internalConfigRepo = builder.ApplicationServices.GetService(); if (UsingConsul(fileConfigRepo)) + { await SetFileConfigInConsul(builder, fileConfigRepo, fileConfig, internalConfigCreator, internalConfigRepo); + } }; private static bool UsingConsul(IFileConfigurationRepository fileConfigRepo) @@ -57,10 +59,16 @@ private static async Task SetFileConfigInConsul(IApplicationBuilder builder, // add the internal config to the internal repo var response = internalConfigRepo.AddOrReplace(internalConfig.Data); - if (IsError(response)) ThrowToStopOcelotStarting(response); + if (IsError(response)) + { + ThrowToStopOcelotStarting(response); + } } - if (IsError(internalConfig)) ThrowToStopOcelotStarting(internalConfig); + if (IsError(internalConfig)) + { + ThrowToStopOcelotStarting(internalConfig); + } } } diff --git a/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs b/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs index afa231dd3..724c6fb9d 100644 --- a/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs +++ b/src/Ocelot.Provider.Consul/ConsulProviderFactory.cs @@ -29,11 +29,15 @@ private static IServiceDiscoveryProvider CreateProvider(IServiceProvider provide var consulProvider = new Consul(consulRegistryConfiguration, factory, consulFactory); if (PollConsul.Equals(config.Type, StringComparison.OrdinalIgnoreCase)) + { lock (LockObject) { var discoveryProvider = ServiceDiscoveryProviders.FirstOrDefault(x => x.ServiceName == route.ServiceName); - if (discoveryProvider != null) return discoveryProvider; + if (discoveryProvider != null) + { + return discoveryProvider; + } discoveryProvider = new PollConsul( config.PollingInterval, route.ServiceName, factory, consulProvider); @@ -41,6 +45,7 @@ private static IServiceDiscoveryProvider CreateProvider(IServiceProvider provide return discoveryProvider; } + } return consulProvider; } diff --git a/src/Ocelot.Provider.Eureka/Eureka.cs b/src/Ocelot.Provider.Eureka/Eureka.cs index 49756e9d2..cbb73785f 100644 --- a/src/Ocelot.Provider.Eureka/Eureka.cs +++ b/src/Ocelot.Provider.Eureka/Eureka.cs @@ -1,6 +1,5 @@ using Ocelot.ServiceDiscovery.Providers; -using Ocelot.Values; -using Steeltoe.Discovery; +using Ocelot.Values; namespace Ocelot.Provider.Eureka {