diff --git a/EventsHandler/Api/EventsHandler/Configuration/WebApiConfiguration.cs b/EventsHandler/Api/EventsHandler/Configuration/WebApiConfiguration.cs
index 35fe6391..d8e961dd 100644
--- a/EventsHandler/Api/EventsHandler/Configuration/WebApiConfiguration.cs
+++ b/EventsHandler/Api/EventsHandler/Configuration/WebApiConfiguration.cs
@@ -3,7 +3,6 @@
using EventsHandler.Extensions;
using EventsHandler.Services.DataLoading.Interfaces;
using EventsHandler.Services.DataLoading.Strategy.Interfaces;
-using System.Collections.Concurrent;
namespace EventsHandler.Configuration
{
@@ -39,25 +38,6 @@ public WebApiConfiguration(ILoadersContext loaderContext) // NOTE: The only con
///
internal abstract record BaseComponent
{
- ///
- /// A thread-safe dictionary, storing cached configuration values.
- ///
- /// The reasons to use such solution are:
- ///
- /// - Some values are validated during retrieval time, whether they have correct format or range.
- /// After being loaded for the first time and then validated, there is no reason to check them again.
- ///
- ///
- /// - The methods used to map specific configurations (like in fluent builder design pattern) is very handy
- /// in terms of OOP approach, but might introduce some minimal overhead. Thanks to caching values by their
- /// configuration nodes, both - flexibility and convenience as well as better performance can be achieved.
- ///
- ///
- ///
- private protected static readonly ConcurrentDictionary<
- string /* Config path */,
- string /* Config value */> s_cachedValues = new();
-
///
internal AuthorizationComponent Authorization { get; }
@@ -106,27 +86,27 @@ internal JwtComponent(ILoadersContext loadersContext, string parentPath)
///
internal string Secret()
- => GetCachedValue(this._loadersContext, s_cachedValues, this._currentPath, nameof(Secret));
+ => GetValue(this._loadersContext, this._currentPath, nameof(Secret));
///
internal string Issuer()
- => GetCachedValue(this._loadersContext, s_cachedValues, this._currentPath, nameof(Issuer));
+ => GetValue(this._loadersContext, this._currentPath, nameof(Issuer));
///
internal string Audience()
- => GetCachedValue(this._loadersContext, s_cachedValues, this._currentPath, nameof(Audience));
+ => GetValue(this._loadersContext, this._currentPath, nameof(Audience));
///
internal ushort ExpiresInMin()
- => GetCachedValue(this._loadersContext, this._currentPath, nameof(ExpiresInMin));
+ => GetValue(this._loadersContext, this._currentPath, nameof(ExpiresInMin));
///
internal string UserId()
- => GetCachedValue(this._loadersContext, s_cachedValues, this._currentPath, nameof(UserId));
+ => GetValue(this._loadersContext, this._currentPath, nameof(UserId));
///
internal string UserName()
- => GetCachedValue(this._loadersContext, s_cachedValues, this._currentPath, nameof(UserName));
+ => GetValue(this._loadersContext, this._currentPath, nameof(UserName));
}
}
}
@@ -167,7 +147,7 @@ internal ApiComponent(ILoadersContext loadersContext, string parentPath)
///
internal string BaseUrl()
- => GetCachedValue(this._loadersContext, s_cachedValues, this._currentPath, nameof(BaseUrl));
+ => GetValue(this._loadersContext, this._currentPath, nameof(BaseUrl));
}
}
@@ -233,11 +213,11 @@ internal KeyComponent(ILoadersContext loadersContext, string parentPath)
///
internal string NotifyNL()
- => GetCachedValue(this._loadersContext, s_cachedValues, this._currentPath, nameof(NotifyNL));
+ => GetValue(this._loadersContext, this._currentPath, nameof(NotifyNL));
///
internal string Objecten()
- => GetCachedValue(this._loadersContext, s_cachedValues, this._currentPath, nameof(Objecten));
+ => GetValue(this._loadersContext, this._currentPath, nameof(Objecten));
}
}
@@ -246,10 +226,6 @@ internal string Objecten()
///
internal sealed record DomainComponent
{
- private static readonly ConcurrentDictionary<
- string /* Config path */,
- string /* Config value */> s_cachedDomainValues = new();
-
private readonly ILoadersContext _loadersContext;
private readonly string _currentPath;
@@ -264,23 +240,23 @@ internal DomainComponent(ILoadersContext loadersContext, string parentPath)
///
internal string OpenNotificaties()
- => GetCachedDomainValue(this._loadersContext, s_cachedDomainValues, this._currentPath, nameof(OpenNotificaties));
+ => GetDomainValue(this._loadersContext, this._currentPath, nameof(OpenNotificaties));
///
internal string OpenZaak()
- => GetCachedDomainValue(this._loadersContext, s_cachedDomainValues, this._currentPath, nameof(OpenZaak));
+ => GetDomainValue(this._loadersContext, this._currentPath, nameof(OpenZaak));
///
internal string OpenKlant()
- => GetCachedDomainValue(this._loadersContext, s_cachedDomainValues, this._currentPath, nameof(OpenKlant));
+ => GetDomainValue(this._loadersContext, this._currentPath, nameof(OpenKlant));
///
internal string Objecten()
- => GetCachedDomainValue(this._loadersContext, s_cachedDomainValues, this._currentPath, nameof(Objecten));
+ => GetDomainValue(this._loadersContext, this._currentPath, nameof(Objecten));
///
internal string ObjectTypen()
- => GetCachedDomainValue(this._loadersContext, s_cachedDomainValues, this._currentPath, nameof(ObjectTypen));
+ => GetDomainValue(this._loadersContext, this._currentPath, nameof(ObjectTypen));
}
///
@@ -310,10 +286,6 @@ internal TemplateIdsComponent(ILoadersContext loadersContext, string parentPath)
///
internal sealed record SmsComponent
{
- private static readonly ConcurrentDictionary<
- string /* Config path */,
- string /* Config value */> s_cachedSmsTemplateValues = new();
-
private readonly ILoadersContext _loadersContext;
private readonly string _currentPath;
@@ -328,15 +300,15 @@ internal SmsComponent(ILoadersContext loadersContext, string parentPath)
///
internal string ZaakCreate()
- => GetCachedTemplateIdValue(this._loadersContext, s_cachedSmsTemplateValues, this._currentPath, nameof(ZaakCreate));
+ => GetTemplateIdValue(this._loadersContext, this._currentPath, nameof(ZaakCreate));
///
internal string ZaakUpdate()
- => GetCachedTemplateIdValue(this._loadersContext, s_cachedSmsTemplateValues, this._currentPath, nameof(ZaakUpdate));
+ => GetTemplateIdValue(this._loadersContext, this._currentPath, nameof(ZaakUpdate));
///
internal string ZaakClose()
- => GetCachedTemplateIdValue(this._loadersContext, s_cachedSmsTemplateValues, this._currentPath, nameof(ZaakClose));
+ => GetTemplateIdValue(this._loadersContext, this._currentPath, nameof(ZaakClose));
}
///
@@ -344,10 +316,6 @@ internal string ZaakClose()
///
internal sealed record EmailComponent
{
- private static readonly ConcurrentDictionary<
- string /* Config path */,
- string /* Config value */> s_cachedEmailTemplateValues = new();
-
private readonly ILoadersContext _loadersContext;
private readonly string _currentPath;
@@ -362,15 +330,15 @@ internal EmailComponent(ILoadersContext loadersContext, string parentPath)
///
internal string ZaakCreate()
- => GetCachedTemplateIdValue(this._loadersContext, s_cachedEmailTemplateValues, this._currentPath, nameof(ZaakCreate));
+ => GetTemplateIdValue(this._loadersContext, this._currentPath, nameof(ZaakCreate));
///
internal string ZaakUpdate()
- => GetCachedTemplateIdValue(this._loadersContext, s_cachedEmailTemplateValues, this._currentPath, nameof(ZaakUpdate));
+ => GetTemplateIdValue(this._loadersContext, this._currentPath, nameof(ZaakUpdate));
///
internal string ZaakClose()
- => GetCachedTemplateIdValue(this._loadersContext, s_cachedEmailTemplateValues, this._currentPath, nameof(ZaakClose));
+ => GetTemplateIdValue(this._loadersContext, this._currentPath, nameof(ZaakClose));
}
}
}
@@ -379,26 +347,17 @@ internal string ZaakClose()
///
/// Retrieves cached configuration value.
///
- private static string GetCachedValue(
- ILoadingService loadersContext,
- ConcurrentDictionary cachedValues,
- string currentPath,
- string nodeName)
+ private static string GetValue(ILoadingService loadersContext, string currentPath, string nodeName)
{
string finalPath = loadersContext.GetPathWithNode(currentPath, nodeName);
- return cachedValues.GetOrAdd(
- nodeName,
- loadersContext.GetData(finalPath));
+ return loadersContext.GetData(finalPath);
}
///
/// Retrieves cached configuration value.
///
- private static TData GetCachedValue(
- ILoadingService loadersContext,
- string currentPath,
- string nodeName)
+ private static TData GetValue(ILoadingService loadersContext, string currentPath, string nodeName)
{
string finalPath = loadersContext.GetPathWithNode(currentPath, nodeName);
@@ -408,34 +367,22 @@ private static TData GetCachedValue(
///
/// Retrieves cached configuration value, ensuring it will be a domain (without http/s and API endpoint).
///
- private static string GetCachedDomainValue(
- ILoadingService loadersContext,
- ConcurrentDictionary cachedValues,
- string currentPath,
- string nodeName)
+ private static string GetDomainValue(ILoadingService loadersContext, string currentPath, string nodeName)
{
- return cachedValues.GetOrAdd(
- nodeName,
- GetCachedValue(loadersContext, cachedValues, currentPath, nodeName)
+ return GetValue(loadersContext, currentPath, nodeName)
// NOTE: Validate only once when the value is cached
.WithoutHttp()
- .WithoutEndpoint());
+ .WithoutEndpoint();
}
///
/// Retrieves cached configuration value, ensuring it will be a valid Template Id.
///
- private static string GetCachedTemplateIdValue(
- ILoadingService loadersContext,
- ConcurrentDictionary cachedValues,
- string currentPath,
- string nodeName)
+ private static string GetTemplateIdValue(ILoadingService loadersContext, string currentPath, string nodeName)
{
- return cachedValues.GetOrAdd(
- nodeName,
- GetCachedValue(loadersContext, cachedValues, currentPath, nodeName)
+ return GetValue(loadersContext, currentPath, nodeName)
// NOTE: Validate only once when the value is cached
- .ValidTemplateId());
+ .ValidTemplateId();
}
#endregion
}