use of io.datarouter.storage.servertype.ServerType in project datarouter by hotpads.
the class ClusterSettingService method getSettingValueForWebappInstance.
public <T> T getSettingValueForWebappInstance(CachedSetting<T> memorySetting, WebappInstance webappInstance) {
// try database first
List<ClusterSetting> settingsWithName = clusterSettingFinder.getAllSettingsWithName(memorySetting.getName());
Optional<ClusterSetting> mostSpecificSetting = ClusterSettingComparisonTool.getMostSpecificSettingForWebappInstance(settingsWithName, webappInstance);
if (mostSpecificSetting.isPresent()) {
return ClusterSettingComparisonTool.getTypedValueOrUseDefaultFrom(mostSpecificSetting, memorySetting);
}
// use default
var environmentType = environmentTypeSupplier.getDatarouterEnvironmentType();
DefaultSettingValue<T> defaultSettingValue = memorySetting.getDefaultSettingValue();
ServerType serverType = serverTypes.fromPersistentString(webappInstance.getServerType());
List<DatarouterSettingTag> settingTags = cachedClusterSettingTags.get();
return defaultSettingValue.getValue(environmentType, environmentName.get(), serverType, serverName.get(), settingTags);
}
Aggregations