Search in sources :

Example 1 with ServerType

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);
}
Also used : ServerType(io.datarouter.storage.servertype.ServerType) ClusterSetting(io.datarouter.clustersetting.storage.clustersetting.ClusterSetting) DatarouterSettingTag(io.datarouter.storage.setting.DatarouterSettingTag)

Aggregations

ClusterSetting (io.datarouter.clustersetting.storage.clustersetting.ClusterSetting)1 ServerType (io.datarouter.storage.servertype.ServerType)1 DatarouterSettingTag (io.datarouter.storage.setting.DatarouterSettingTag)1