-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
301 additions
and
254 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...config-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/DesignerConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package pl.touk.nussknacker.ui.configloader | ||
|
||
import com.typesafe.config.Config | ||
import pl.touk.nussknacker.engine.util.Implicits.RichScalaMap | ||
import pl.touk.nussknacker.engine.{ConfigWithUnresolvedVersion, ProcessingTypeConfig} | ||
|
||
// TODO: We should extract a class for all configuration options that should be available to designer instead of returning raw hocon config. | ||
// Thanks to that it will be easier to split processing type config from rest of configs and use this interface programmatically | ||
final case class DesignerConfig private (rawConfig: ConfigWithUnresolvedVersion) { | ||
|
||
def processingTypeConfigs: Map[String, ProcessingTypeConfig] = { | ||
rawConfig | ||
.readMap("scenarioTypes") | ||
.getOrElse { | ||
throw new RuntimeException("No scenario types configuration provided") | ||
} | ||
.mapValuesNow(ProcessingTypeConfig.read) | ||
} | ||
|
||
} | ||
|
||
object DesignerConfig { | ||
|
||
def from(config: Config): DesignerConfig = { | ||
DesignerConfig(ConfigWithUnresolvedVersion(config)) | ||
} | ||
|
||
} |
16 changes: 0 additions & 16 deletions
16
...ig-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/DesignerRootConfig.scala
This file was deleted.
Oops, something went wrong.
17 changes: 1 addition & 16 deletions
17
...-api/src/main/scala/pl/touk/nussknacker/ui/configloader/ProcessingTypeConfigsLoader.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,10 @@ | ||
package pl.touk.nussknacker.ui.configloader | ||
|
||
import com.typesafe.scalalogging.LazyLogging | ||
import pl.touk.nussknacker.engine.ProcessingTypeConfig | ||
import pl.touk.nussknacker.engine.util.Implicits.RichScalaMap | ||
import cats.effect.IO | ||
import pl.touk.nussknacker.engine.ProcessingTypeConfig | ||
|
||
trait ProcessingTypeConfigsLoader { | ||
|
||
def loadProcessingTypeConfigs(): IO[Map[String, ProcessingTypeConfig]] | ||
|
||
} | ||
|
||
object ProcessingTypeConfigsLoader extends LazyLogging { | ||
|
||
def extractProcessingTypeConfigs(rootConfig: DesignerRootConfig): Map[String, ProcessingTypeConfig] = { | ||
rootConfig.rawConfig | ||
.readMap("scenarioTypes") | ||
.getOrElse { | ||
throw new RuntimeException("No scenario types configuration provided") | ||
} | ||
.mapValuesNow(ProcessingTypeConfig.read) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
designer/server/src/main/scala/pl/touk/nussknacker/ui/NussknackerApp.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
designer/server/src/main/scala/pl/touk/nussknacker/ui/config/DesignerConfigLoader.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package pl.touk.nussknacker.ui.config | ||
|
||
import cats.effect.IO | ||
import com.typesafe.config.{Config, ConfigFactory} | ||
import pl.touk.nussknacker.engine.ConfigWithUnresolvedVersion | ||
import pl.touk.nussknacker.engine.util.UriUtils | ||
import pl.touk.nussknacker.engine.util.config.ConfigFactoryExt | ||
import pl.touk.nussknacker.ui.configloader.DesignerConfig | ||
|
||
trait DesignerConfigLoader { | ||
|
||
def loadDesignerConfig(): IO[DesignerConfig] | ||
|
||
} | ||
|
||
/** | ||
* This class handles two parts of ui config loading: | ||
* 1. Parsing of "base" config passed via nussknacker.config.locations system property (without resolution) | ||
* 2. Loading this parsed config with fallback to config inside defaultDesignerConfig.conf resource | ||
* This process is split that way to make possible using "base" configs prepared programmatically - | ||
* see LocalNussknackerWithSingleModel for a sample of such usage | ||
* Result of config loading still keep version with unresolved env variables for purpose of config loading on model side - see | ||
* InputConfigDuringExecution and ModelConfigLoader | ||
*/ | ||
class AlwaysLoadingFileBasedDesignerConfigLoader(classLoader: ClassLoader) extends DesignerConfigLoader { | ||
|
||
private val configLocationsProperty: String = "nussknacker.config.locations" | ||
|
||
private val defaultConfigResource = "defaultDesignerConfig.conf" | ||
|
||
override def loadDesignerConfig(): IO[DesignerConfig] = { | ||
val locationsPropertyValueOpt = Option(System.getProperty(configLocationsProperty)) | ||
val locations = locationsPropertyValueOpt.map(UriUtils.extractListOfLocations).getOrElse(List.empty) | ||
for { | ||
baseUnresolvedConfig <- IO.blocking(new ConfigFactoryExt(classLoader).parseUnresolved(locations)) | ||
parsedDefaultUiConfig <- IO.blocking(ConfigFactory.parseResources(classLoader, defaultConfigResource)) | ||
unresolvedConfigWithFallbackToDefaults = baseUnresolvedConfig.withFallback(parsedDefaultUiConfig) | ||
} yield DesignerConfig(ConfigWithUnresolvedVersion(classLoader, unresolvedConfigWithFallbackToDefaults)) | ||
} | ||
|
||
} | ||
|
||
/** | ||
* This implementation is more straightforward - it only parse config without any property checking and fallbacks | ||
*/ | ||
class SimpleConfigLoadingDesignerConfigLoader(loadConfig: => Config) extends DesignerConfigLoader { | ||
|
||
override def loadDesignerConfig(): IO[DesignerConfig] = IO.delay(DesignerConfig.from(loadConfig)) | ||
|
||
} | ||
|
||
object DesignerConfigLoader { | ||
|
||
def apply(classLoader: ClassLoader): AlwaysLoadingFileBasedDesignerConfigLoader = | ||
new AlwaysLoadingFileBasedDesignerConfigLoader(classLoader) | ||
|
||
def fromConfig(loadConfig: => Config): SimpleConfigLoadingDesignerConfigLoader = | ||
new SimpleConfigLoadingDesignerConfigLoader(loadConfig) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
...ussknacker/ui/config/processingtype/ProcessingTypeConfigsLoaderFactoryServiceLoader.scala
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
...r/server/src/main/scala/pl/touk/nussknacker/ui/config/root/DesignerRootConfigLoader.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.