Skip to content

Commit

Permalink
fix: clear module options cache
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicGD committed Jun 24, 2024
1 parent ca62c43 commit 11e8dcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Sitko.Core.App/ApplicationModuleRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public override (bool isSuccess, IEnumerable<Type> missingModules) CheckRequired

public override bool IsEnabled(IApplicationContext context) => CreateOptions(context).Enabled;

public override void ClearOptionsCache() => optionsCache.Clear();

private TModuleOptions CreateOptions(IApplicationContext applicationContext, bool validateOptions = false)
{
TModuleOptions options;
Expand Down Expand Up @@ -261,4 +263,6 @@ public abstract (bool isSuccess, IEnumerable<Type> missingModules) CheckRequired
Type[] registeredModules);

public abstract bool IsEnabled(IApplicationContext context);

public abstract void ClearOptionsCache();
}
4 changes: 4 additions & 0 deletions src/Sitko.Core.App/SitkoCoreBaseApplicationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ protected virtual LoggerConfiguration ConfigureDefautLogger(LoggerConfiguration
protected virtual void BeforeContainerBuild()
{
var enabledModules = ModulesHelper.GetEnabledModuleRegistrations(BootApplicationContext, moduleRegistrations);
foreach (var applicationModuleRegistration in enabledModules)
{
applicationModuleRegistration.ClearOptionsCache();
}
serilogConfigurator.ApplyLogging(BootApplicationContext, enabledModules);
foreach (var postConfigureCallback in moduleConfigurationCallbacks)
{
Expand Down

0 comments on commit 11e8dcc

Please sign in to comment.