Skip to content

Commit

Permalink
Get ConfigServer PollingInterval from Configuration object (#853)
Browse files Browse the repository at this point in the history
* get config server polling interval from configuration object
* Create_WithPollingTimer failing

Co-authored-by: Hermógenes Ferreira <[email protected]>
Co-authored-by: Dave Tillman <[email protected]>
  • Loading branch information
3 people authored May 25, 2022
1 parent e3140c4 commit bc62967
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static void Initialize(string configPrefix, ConfigServerClientSettings se
settings.DiscoveryServiceId = GetDiscoveryServiceId(clientConfigsection, settings.DiscoveryServiceId);
settings.HealthEnabled = GetHealthEnabled(clientConfigsection, settings.HealthEnabled);
settings.HealthTimeToLive = GetHealthTimeToLive(clientConfigsection, settings.HealthTimeToLive);
settings.PollingInterval = GetPollingInterval(clientConfigsection, settings.PollingInterval);

// Override Config server URI
settings.Uri = GetCloudFoundryUri(configPrefix, config, settings.Uri);
Expand Down Expand Up @@ -176,6 +177,11 @@ private static int GetTokenTtl(IConfigurationSection configServerSection)
return configServerSection.GetValue("tokenTtl", ConfigServerClientSettings.DEFAULT_VAULT_TOKEN_TTL);
}

private static TimeSpan GetPollingInterval(IConfigurationSection clientConfigsection, TimeSpan def)
{
return clientConfigsection.GetValue("pollingInterval", def);
}

private static string GetClientSecret(string configPrefix, IConfiguration config)
{
return ConfigurationValuesHelper.GetSetting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,15 @@ public async Task Create_WithPollingTimer()
using var client = server.CreateClient();
var provider = new ConfigServerConfigurationProvider(settings, client);
var token = provider.GetReloadToken();

await Task.Delay(2000);
var postInitialLoadToken = provider.GetReloadToken();
await Task.Delay(500);

Assert.NotSame(token, postInitialLoadToken);
Assert.NotNull(TestConfigServerStartup.LastRequest);
Assert.True(TestConfigServerStartup.RequestCount > 1);
Assert.True(token.HasChanged);

await Task.Delay(500);
Assert.False(postInitialLoadToken.HasChanged);
}

Expand Down

0 comments on commit bc62967

Please sign in to comment.