mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 14:58:16 +08:00
Activate ChangeToken when Ocelot's configuration changes #1037
* Add configuration change token (#1036) * Add IOptionsMonitor<IInternalConfiguration> * Activate change token from *ConfigurationRepository instead of FileAndInternalConfigurationSetter; add acceptance & integration tests * Update documentation * Use IWebHostEnvironment as IHostingEnvironment deprecated Co-authored-by: Chris Swinchatt <chrisswinchatt@gmail.com>
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
namespace Ocelot.AcceptanceTests
|
||||
using Ocelot.Configuration.ChangeTracking;
|
||||
|
||||
namespace Ocelot.AcceptanceTests
|
||||
{
|
||||
using Caching;
|
||||
using Configuration.Repository;
|
||||
@ -54,6 +56,7 @@
|
||||
private IWebHostBuilder _webHostBuilder;
|
||||
private WebHostBuilder _ocelotBuilder;
|
||||
private IWebHost _ocelotHost;
|
||||
private IOcelotConfigurationChangeTokenSource _changeToken;
|
||||
|
||||
public Steps()
|
||||
{
|
||||
@ -216,6 +219,11 @@
|
||||
_ocelotClient = _ocelotServer.CreateClient();
|
||||
}
|
||||
|
||||
public void GivenIHaveAChangeToken()
|
||||
{
|
||||
_changeToken = _ocelotServer.Host.Services.GetRequiredService<IOcelotConfigurationChangeTokenSource>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is annoying cos it should be in the constructor but we need to set up the file before calling startup so its a step.
|
||||
/// </summary>
|
||||
@ -1123,6 +1131,11 @@
|
||||
_ocelotClient = _ocelotServer.CreateClient();
|
||||
}
|
||||
|
||||
public void TheChangeTokenShouldBeActive(bool itShouldBeActive)
|
||||
{
|
||||
_changeToken.ChangeToken.HasChanged.ShouldBe(itShouldBeActive);
|
||||
}
|
||||
|
||||
public void GivenOcelotIsRunningWithLogger()
|
||||
{
|
||||
_webHostBuilder = new WebHostBuilder();
|
||||
|
Reference in New Issue
Block a user