Skip to content

Commit

Permalink
Some missing braces and commas
Browse files Browse the repository at this point in the history
  • Loading branch information
ggnaegi committed Sep 29, 2023
1 parent 08ac86e commit 77bbaf0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/Ocelot.Provider.Consul/ConsulFileConfigurationRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ public async Task<Response<FileConfiguration>> Get()
{
var config = _cache.Get(_configurationKey, _configurationKey);

if (config != null) return new OkResponse<FileConfiguration>(config);
if (config != null)
{
return new OkResponse<FileConfiguration>(config);
}

var queryResult = await _consul.KV.Get(_configurationKey);

if (queryResult.Response == null) return new OkResponse<FileConfiguration>(null);
if (queryResult.Response == null)
{
return new OkResponse<FileConfiguration>(null);
}

var bytes = queryResult.Response.Value;

Expand All @@ -63,7 +69,7 @@ public async Task<Response> Set(FileConfiguration ocelotConfiguration)

var kvPair = new KVPair(_configurationKey)
{
Value = bytes
Value = bytes,
};

var result = await _consul.KV.Put(kvPair);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public static class ConsulMiddlewareConfigurationProvider
var internalConfigRepo = builder.ApplicationServices.GetService<IInternalConfigurationRepository>();

if (UsingConsul(fileConfigRepo))
{
await SetFileConfigInConsul(builder, fileConfigRepo, fileConfig, internalConfigCreator, internalConfigRepo);
}
};

private static bool UsingConsul(IFileConfigurationRepository fileConfigRepo)
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/Ocelot.Provider.Consul/ConsulProviderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ 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);
ServiceDiscoveryProviders.Add(discoveryProvider);

return discoveryProvider;
}
}

return consulProvider;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Ocelot.Provider.Eureka/Eureka.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Ocelot.ServiceDiscovery.Providers;
using Ocelot.Values;
using Steeltoe.Discovery;
using Ocelot.Values;

namespace Ocelot.Provider.Eureka
{
Expand Down

0 comments on commit 77bbaf0

Please sign in to comment.