diff --git a/.run/NussknackerApp-dist-config.run.xml b/.run/NussknackerApp-dist-config.run.xml
index 3f27dd337b3..3ef7ee7f1ee 100644
--- a/.run/NussknackerApp-dist-config.run.xml
+++ b/.run/NussknackerApp-dist-config.run.xml
@@ -26,7 +26,7 @@
-
+
@@ -34,4 +34,4 @@
-
\ No newline at end of file
+
diff --git a/.run/NussknackerApp-postgres.run.xml b/.run/NussknackerApp-postgres.run.xml
index c3cfc1a7a65..e32b1c3aba8 100644
--- a/.run/NussknackerApp-postgres.run.xml
+++ b/.run/NussknackerApp-postgres.run.xml
@@ -30,7 +30,7 @@
-
+
@@ -38,4 +38,4 @@
-
\ No newline at end of file
+
diff --git a/.run/NussknackerApp.run.xml b/.run/NussknackerApp.run.xml
index 33bb3adf565..4f08f2afcf2 100644
--- a/.run/NussknackerApp.run.xml
+++ b/.run/NussknackerApp.run.xml
@@ -26,7 +26,7 @@
-
+
@@ -34,4 +34,4 @@
-
\ No newline at end of file
+
diff --git a/build.sbt b/build.sbt
index bfe70b61dbd..f96fba1ed0f 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1913,10 +1913,10 @@ lazy val listenerApi = (project in file("designer/listener-api"))
)
.dependsOn(extensionsApi)
-lazy val loadableConfigApi = (project in file("designer/loadable-config-api"))
+lazy val configLoaderApi = (project in file("designer/config-loader-api"))
.settings(commonSettings)
.settings(
- name := "nussknacker-loadable-config-api",
+ name := "nussknacker-config-loader-api",
libraryDependencies ++= {
Seq(
"org.typelevel" %% "cats-effect" % catsEffectV
@@ -2065,7 +2065,7 @@ lazy val designer = (project in file("designer/server"))
deploymentManagerApi,
restmodel,
listenerApi,
- loadableConfigApi,
+ configLoaderApi,
defaultHelpers % Test,
testUtils % Test,
flinkTestUtils % Test,
@@ -2206,7 +2206,7 @@ lazy val modules = List[ProjectReference](
httpUtils,
restmodel,
listenerApi,
- loadableConfigApi,
+ configLoaderApi,
deploymentManagerApi,
designer,
sqlComponents,
diff --git a/designer/loadable-config-api/src/main/scala/pl/touk/nussknacker/ui/loadableconfig/DesignerRootConfig.scala b/designer/config-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/DesignerRootConfig.scala
similarity index 92%
rename from designer/loadable-config-api/src/main/scala/pl/touk/nussknacker/ui/loadableconfig/DesignerRootConfig.scala
rename to designer/config-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/DesignerRootConfig.scala
index 11df368c849..467036e199f 100644
--- a/designer/loadable-config-api/src/main/scala/pl/touk/nussknacker/ui/loadableconfig/DesignerRootConfig.scala
+++ b/designer/config-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/DesignerRootConfig.scala
@@ -1,4 +1,4 @@
-package pl.touk.nussknacker.ui.loadableconfig
+package pl.touk.nussknacker.ui.configloader
import com.typesafe.config.Config
import pl.touk.nussknacker.engine.ConfigWithUnresolvedVersion
diff --git a/designer/loadable-config-api/src/main/scala/pl/touk/nussknacker/ui/loadableconfig/LoadableProcessingTypeConfigs.scala b/designer/config-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/ProcessingTypeConfigsLoader.scala
similarity index 60%
rename from designer/loadable-config-api/src/main/scala/pl/touk/nussknacker/ui/loadableconfig/LoadableProcessingTypeConfigs.scala
rename to designer/config-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/ProcessingTypeConfigsLoader.scala
index 6139ffaf3d1..2c287be0aed 100644
--- a/designer/loadable-config-api/src/main/scala/pl/touk/nussknacker/ui/loadableconfig/LoadableProcessingTypeConfigs.scala
+++ b/designer/config-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/ProcessingTypeConfigsLoader.scala
@@ -1,18 +1,17 @@
-package pl.touk.nussknacker.ui.loadableconfig
+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
-trait LoadableProcessingTypeConfigs {
+trait ProcessingTypeConfigsLoader {
- // rootConfigLoadedAtStart is used for external project purpose - don't remove it
- def loadProcessingTypeConfigs(rootConfigLoadedAtStart: DesignerRootConfig): IO[Map[String, ProcessingTypeConfig]]
+ def loadProcessingTypeConfigs(): IO[Map[String, ProcessingTypeConfig]]
}
-object LoadableProcessingTypeConfigs extends LazyLogging {
+object ProcessingTypeConfigsLoader extends LazyLogging {
def extractProcessingTypeConfigs(rootConfig: DesignerRootConfig): Map[String, ProcessingTypeConfig] = {
rootConfig.rawConfig
diff --git a/designer/config-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/ProcessingTypeConfigsLoaderFactory.scala b/designer/config-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/ProcessingTypeConfigsLoaderFactory.scala
new file mode 100644
index 00000000000..25a54d3fc81
--- /dev/null
+++ b/designer/config-loader-api/src/main/scala/pl/touk/nussknacker/ui/configloader/ProcessingTypeConfigsLoaderFactory.scala
@@ -0,0 +1,15 @@
+package pl.touk.nussknacker.ui.configloader
+
+import sttp.client3.SttpBackend
+
+import scala.concurrent.{ExecutionContext, Future}
+
+trait ProcessingTypeConfigsLoaderFactory {
+
+ def create(
+ designerRootConfigLoadedAtStart: DesignerRootConfig,
+ sttpBackend: SttpBackend[Future, Any],
+ ec: ExecutionContext
+ ): ProcessingTypeConfigsLoader
+
+}
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/LocalNussknackerWithSingleModel.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/LocalNussknackerWithSingleModel.scala
index 3514e6b5031..52e88c8b6b6 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/LocalNussknackerWithSingleModel.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/LocalNussknackerWithSingleModel.scala
@@ -4,9 +4,8 @@ import cats.effect.{IO, Resource}
import com.typesafe.config.{Config, ConfigFactory}
import org.apache.commons.io.FileUtils
import pl.touk.nussknacker.engine.{DeploymentManagerProvider, ModelData}
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
import pl.touk.nussknacker.ui.factory.NussknackerAppFactory
-import pl.touk.nussknacker.ui.config.root.LoadableDesignerRootConfig
+import pl.touk.nussknacker.ui.config.root.DesignerRootConfigLoader
import pl.touk.nussknacker.ui.process.processingtype.loader.LocalProcessingTypeDataLoader
import java.io.File
@@ -50,8 +49,12 @@ object LocalNussknackerWithSingleModel {
modelData = Map(typeName -> (category, modelData)),
deploymentManagerProvider = deploymentManagerProvider
)
- val loadableDesignerConfig = LoadableDesignerRootConfig(IO.delay(DesignerRootConfig.from(appConfig)))
- val appFactory = new NussknackerAppFactory(loadableDesignerConfig, local)
+ val designerConfigLoader = DesignerRootConfigLoader.fromConfig(appConfig)
+ val appFactory = new NussknackerAppFactory(
+ designerConfigLoader,
+ (_, _, _) => () => IO.pure(Map.empty),
+ _ => local
+ )
appFactory.createApp()
}
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/NussknackerApp.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/NussknackerApp.scala
index 68f34e19cc3..21803765f4c 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/NussknackerApp.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/NussknackerApp.scala
@@ -3,16 +3,13 @@ package pl.touk.nussknacker.ui
import cats.effect.{ExitCode, IO, IOApp}
import pl.touk.nussknacker.ui.config.root.DesignerRootConfigLoader
import pl.touk.nussknacker.ui.factory.NussknackerAppFactory
-import pl.touk.nussknacker.ui.config.root.LoadableDesignerRootConfig
object NussknackerApp extends IOApp {
override def run(args: List[String]): IO[ExitCode] = {
for {
- appFactory <- IO(
- NussknackerAppFactory(LoadableDesignerRootConfig(DesignerRootConfigLoader.load(getClass.getClassLoader)))
- )
- _ <- appFactory.createApp().use { _ => IO.never }
+ appFactory <- IO(NussknackerAppFactory(DesignerRootConfigLoader(getClass.getClassLoader)))
+ _ <- appFactory.createApp().use { _ => IO.never }
} yield ExitCode.Success
}
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/DictApiEndpoints.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/DictApiEndpoints.scala
index 36df4adceef..bb8d7486438 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/DictApiEndpoints.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/DictApiEndpoints.scala
@@ -15,9 +15,8 @@ import pl.touk.nussknacker.ui.api.description.DictApiEndpoints.DictError.{
}
import pl.touk.nussknacker.ui.api.description.DictApiEndpoints.Dtos._
import sttp.model.StatusCode.{BadRequest, NotFound, Ok}
-import sttp.tapir._
+import sttp.tapir.{Schema, _}
import sttp.tapir.json.circe._
-import sttp.tapir.Schema
import scala.language.implicitConversions
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/UserApiEndpoints.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/UserApiEndpoints.scala
index dc745e625d5..1095c09e4d6 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/UserApiEndpoints.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/UserApiEndpoints.scala
@@ -6,7 +6,7 @@ import pl.touk.nussknacker.restmodel.BaseEndpointDefinitions
import pl.touk.nussknacker.restmodel.BaseEndpointDefinitions.SecuredEndpoint
import pl.touk.nussknacker.security.AuthCredentials
import pl.touk.nussknacker.ui.security.api.GlobalPermission.GlobalPermission
-import pl.touk.nussknacker.ui.security.api.{AdminUser, CommonUser, ImpersonatedUser, LoggedUser, RealLoggedUser}
+import pl.touk.nussknacker.ui.security.api._
import sttp.model.StatusCode.Ok
import sttp.tapir.EndpointIO.Example
import sttp.tapir.derevo.schema
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/scenarioActivity/InputOutput.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/scenarioActivity/InputOutput.scala
index b475bab6015..317ebf02054 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/scenarioActivity/InputOutput.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/api/description/scenarioActivity/InputOutput.scala
@@ -3,9 +3,9 @@ package pl.touk.nussknacker.ui.api.description.scenarioActivity
import pl.touk.nussknacker.engine.api.process.ProcessName
import pl.touk.nussknacker.ui.api.description.scenarioActivity.Dtos.ScenarioActivityError
import pl.touk.nussknacker.ui.api.description.scenarioActivity.Dtos.ScenarioActivityError.NoScenario
-import sttp.model.StatusCode.{NotFound, NotImplemented}
+import sttp.model.StatusCode.NotFound
import sttp.tapir.EndpointIO.Example
-import sttp.tapir.{EndpointOutput, emptyOutputAs, oneOf, oneOfVariantFromMatchType, plainBody}
+import sttp.tapir.{EndpointOutput, oneOf, oneOfVariantFromMatchType, plainBody}
object InputOutput {
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigLoadableProcessingTypeConfigs.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigLoadableProcessingTypeConfigs.scala
deleted file mode 100644
index 1df63dc6cf3..00000000000
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigLoadableProcessingTypeConfigs.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-package pl.touk.nussknacker.ui.config.processingtype
-
-import cats.effect.IO
-import pl.touk.nussknacker.engine.ProcessingTypeConfig
-import pl.touk.nussknacker.ui.config.root.LoadableDesignerRootConfig
-import pl.touk.nussknacker.ui.loadableconfig.{DesignerRootConfig, LoadableProcessingTypeConfigs}
-
-class EachTimeLoadingRootConfigLoadableProcessingTypeConfigs(loadableDesignerRootConfig: LoadableDesignerRootConfig)
- extends LoadableProcessingTypeConfigs {
-
- def loadProcessingTypeConfigs(
- rootConfigLoadedAtStart: DesignerRootConfig
- ): IO[Map[String, ProcessingTypeConfig]] =
- loadableDesignerRootConfig
- .loadDesignerRootConfig()
- .map(LoadableProcessingTypeConfigs.extractProcessingTypeConfigs)
-
-}
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigProcessingTypeConfigsLoader.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigProcessingTypeConfigsLoader.scala
new file mode 100644
index 00000000000..73808f16633
--- /dev/null
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigProcessingTypeConfigsLoader.scala
@@ -0,0 +1,16 @@
+package pl.touk.nussknacker.ui.config.processingtype
+
+import cats.effect.IO
+import pl.touk.nussknacker.engine.ProcessingTypeConfig
+import pl.touk.nussknacker.ui.config.root.DesignerRootConfigLoader
+import pl.touk.nussknacker.ui.configloader.ProcessingTypeConfigsLoader
+
+class EachTimeLoadingRootConfigProcessingTypeConfigsLoader(designerRootConfigLoader: DesignerRootConfigLoader)
+ extends ProcessingTypeConfigsLoader {
+
+ def loadProcessingTypeConfigs(): IO[Map[String, ProcessingTypeConfig]] =
+ designerRootConfigLoader
+ .loadDesignerRootConfig()
+ .map(ProcessingTypeConfigsLoader.extractProcessingTypeConfigs)
+
+}
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/LoadableProcessingTypeConfigsFactory.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/LoadableProcessingTypeConfigsFactory.scala
deleted file mode 100644
index 39c7fc5f7ee..00000000000
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/LoadableProcessingTypeConfigsFactory.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-package pl.touk.nussknacker.ui.config.processingtype
-
-import com.typesafe.scalalogging.LazyLogging
-import pl.touk.nussknacker.engine.util.loader.ScalaServiceLoader
-import pl.touk.nussknacker.ui.config.root.LoadableDesignerRootConfig
-import pl.touk.nussknacker.ui.loadableconfig.LoadableProcessingTypeConfigs
-
-object LoadableProcessingTypeConfigsFactory extends LazyLogging {
-
- def create(loadableDesignerRootConfig: LoadableDesignerRootConfig): LoadableProcessingTypeConfigs = {
- ScalaServiceLoader.load[LoadableProcessingTypeConfigs](getClass.getClassLoader) match {
- case one :: Nil =>
- logger.debug(
- s"Found custom ${classOf[LoadableProcessingTypeConfigs].getSimpleName}: ${one.getClass.getName}. Using it for configuration loading"
- )
- one
- case Nil =>
- logger.debug(s"No custom ${classOf[LoadableProcessingTypeConfigs].getSimpleName} found. Using the default one")
- new EachTimeLoadingRootConfigLoadableProcessingTypeConfigs(loadableDesignerRootConfig)
- case _ =>
- throw new IllegalStateException(s"More than one ${classOf[LoadableProcessingTypeConfigs].getSimpleName} found")
- }
- }
-
-}
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/ProcessingTypeConfigsLoaderFactoryServiceLoader.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/ProcessingTypeConfigsLoaderFactoryServiceLoader.scala
new file mode 100644
index 00000000000..7f784e13f5c
--- /dev/null
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/processingtype/ProcessingTypeConfigsLoaderFactoryServiceLoader.scala
@@ -0,0 +1,35 @@
+package pl.touk.nussknacker.ui.config.processingtype
+
+import com.typesafe.scalalogging.LazyLogging
+import pl.touk.nussknacker.engine.util.loader.ScalaServiceLoader
+import pl.touk.nussknacker.ui.config.root.DesignerRootConfigLoader
+import pl.touk.nussknacker.ui.configloader.{
+ DesignerRootConfig,
+ ProcessingTypeConfigsLoader,
+ ProcessingTypeConfigsLoaderFactory
+}
+import sttp.client3.SttpBackend
+
+import scala.concurrent.{ExecutionContext, Future}
+
+object ProcessingTypeConfigsLoaderFactoryServiceLoader extends LazyLogging {
+
+ def loadService(designerRootConfigLoader: DesignerRootConfigLoader): ProcessingTypeConfigsLoaderFactory = {
+ ScalaServiceLoader.load[ProcessingTypeConfigsLoaderFactory](getClass.getClassLoader) match {
+ case one :: Nil =>
+ logger.debug(
+ s"Found custom ${classOf[ProcessingTypeConfigsLoaderFactory].getSimpleName}: ${one.getClass.getName}. Using it for configuration loading"
+ )
+ one
+ case Nil =>
+ logger.debug(
+ s"No custom ${classOf[ProcessingTypeConfigsLoaderFactory].getSimpleName} found. Using the default one"
+ )
+ (_: DesignerRootConfig, _: SttpBackend[Future, Any], _: ExecutionContext) =>
+ new EachTimeLoadingRootConfigProcessingTypeConfigsLoader(designerRootConfigLoader)
+ case _ =>
+ throw new IllegalStateException(s"More than one ${classOf[ProcessingTypeConfigsLoader].getSimpleName} found")
+ }
+ }
+
+}
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/root/DesignerRootConfigLoader.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/root/DesignerRootConfigLoader.scala
index b2a90c4ec14..64b675d953f 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/root/DesignerRootConfigLoader.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/root/DesignerRootConfigLoader.scala
@@ -4,7 +4,13 @@ import cats.effect.IO
import com.typesafe.config.{Config, ConfigFactory}
import pl.touk.nussknacker.engine.ConfigWithUnresolvedVersion
import pl.touk.nussknacker.engine.util.config.ConfigFactoryExt
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
+import pl.touk.nussknacker.ui.configloader.DesignerRootConfig
+
+trait DesignerRootConfigLoader {
+
+ def loadDesignerRootConfig(): IO[DesignerRootConfig]
+
+}
/**
* This class handles two parts of ui config loading:
@@ -15,18 +21,18 @@ import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
* Result of config loading still keep version with unresolved env variables for purpose of config loading on model side - see
* InputConfigDuringExecution and ModelConfigLoader
*/
-object DesignerRootConfigLoader {
+private[root] class DesignerRootConfigLoaderImpl(classLoader: ClassLoader) extends DesignerRootConfigLoader {
private val defaultConfigResource = "defaultDesignerConfig.conf"
- def load(classLoader: ClassLoader): IO[DesignerRootConfig] = {
+ override def loadDesignerRootConfig(): IO[DesignerRootConfig] = {
for {
baseConfig <- IO.blocking(ConfigFactoryExt.parseUnresolved(classLoader = classLoader))
- loadedConfig <- load(baseConfig, classLoader)
+ loadedConfig <- load(baseConfig)
} yield DesignerRootConfig(loadedConfig)
}
- def load(baseUnresolvedConfig: Config, classLoader: ClassLoader): IO[ConfigWithUnresolvedVersion] = {
+ def load(baseUnresolvedConfig: Config): IO[ConfigWithUnresolvedVersion] = {
IO.blocking {
val parsedDefaultUiConfig = ConfigFactory.parseResources(classLoader, defaultConfigResource)
val unresolvedConfigWithFallbackToDefaults = baseUnresolvedConfig.withFallback(parsedDefaultUiConfig)
@@ -36,3 +42,10 @@ object DesignerRootConfigLoader {
}
+object DesignerRootConfigLoader {
+
+ def apply(classLoader: ClassLoader): DesignerRootConfigLoader = new DesignerRootConfigLoaderImpl(classLoader)
+
+ def fromConfig(config: => Config): DesignerRootConfigLoader = () => IO.delay(DesignerRootConfig.from(config))
+
+}
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/root/LoadableDesignerRootConfig.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/root/LoadableDesignerRootConfig.scala
deleted file mode 100644
index 417f1d42538..00000000000
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/config/root/LoadableDesignerRootConfig.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-package pl.touk.nussknacker.ui.config.root
-
-import cats.effect.IO
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
-
-trait LoadableDesignerRootConfig {
-
- def loadDesignerRootConfig(): IO[DesignerRootConfig]
-
-}
-
-object LoadableDesignerRootConfig {
-
- def apply(loadConfig: IO[DesignerRootConfig]): LoadableDesignerRootConfig = { () =>
- loadConfig
- }
-
-}
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/entity/BaseEntityFactory.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/entity/BaseEntityFactory.scala
index 68b7f22e920..40baaff6cc4 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/entity/BaseEntityFactory.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/entity/BaseEntityFactory.scala
@@ -9,8 +9,7 @@ import pl.touk.nussknacker.engine.api.deployment.{
}
import pl.touk.nussknacker.engine.api.process.{ProcessId, ProcessName, VersionId}
import pl.touk.nussknacker.engine.newdeployment.DeploymentId
-import slick.ast.BaseTypedType
-import slick.jdbc.{JdbcProfile, JdbcType}
+import slick.jdbc.JdbcProfile
import java.util.UUID
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/entity/ProcessEntityFactory.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/entity/ProcessEntityFactory.scala
index a16f394a22b..0edcf8e1b52 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/entity/ProcessEntityFactory.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/entity/ProcessEntityFactory.scala
@@ -1,7 +1,6 @@
package pl.touk.nussknacker.ui.db.entity
-import pl.touk.nussknacker.engine.api.process.{ProcessId, ProcessName}
-import pl.touk.nussknacker.engine.api.process.ProcessingType
+import pl.touk.nussknacker.engine.api.process.{ProcessId, ProcessName, ProcessingType}
import slick.lifted.{ProvenShape, TableQuery => LTableQuery}
import slick.sql.SqlProfile.ColumnOption.NotNull
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/timeseries/questdb/QuestDbFEStatisticsRepository.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/timeseries/questdb/QuestDbFEStatisticsRepository.scala
index f69597bb6de..ee78f21a61f 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/timeseries/questdb/QuestDbFEStatisticsRepository.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/db/timeseries/questdb/QuestDbFEStatisticsRepository.scala
@@ -10,7 +10,6 @@ import io.questdb.cairo.security.AllowAllSecurityContext
import io.questdb.cairo.sql.RecordCursorFactory
import io.questdb.cairo.wal.WalWriter
import io.questdb.griffin.{SqlExecutionContext, SqlExecutionContextImpl}
-import pl.touk.nussknacker.ui.db.timeseries.{FEStatisticsRepository, NoOpFEStatisticsRepository}
import pl.touk.nussknacker.ui.db.timeseries.questdb.QuestDbExtensions.{
BuildCairoEngineExtension,
CairoEngineExtension,
@@ -22,6 +21,7 @@ import pl.touk.nussknacker.ui.db.timeseries.questdb.QuestDbFEStatisticsRepositor
selectQuery,
tableName
}
+import pl.touk.nussknacker.ui.db.timeseries.{FEStatisticsRepository, NoOpFEStatisticsRepository}
import pl.touk.nussknacker.ui.statistics.RawFEStatistics
import java.time.Clock
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/factory/NussknackerAppFactory.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/factory/NussknackerAppFactory.scala
index a7307e494de..0d66661b2ff 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/factory/NussknackerAppFactory.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/factory/NussknackerAppFactory.scala
@@ -8,25 +8,41 @@ import io.dropwizard.metrics5.MetricRegistry
import io.dropwizard.metrics5.jmx.JmxReporter
import pl.touk.nussknacker.engine.ConfigWithUnresolvedVersion
import pl.touk.nussknacker.engine.util.{JavaClassVersionChecker, SLF4JBridgeHandlerRegistrar}
-import pl.touk.nussknacker.ui.config.root.LoadableDesignerRootConfig
-import pl.touk.nussknacker.ui.config.processingtype.LoadableProcessingTypeConfigsFactory
+import pl.touk.nussknacker.ui.config.processingtype.ProcessingTypeConfigsLoaderFactoryServiceLoader
+import pl.touk.nussknacker.ui.config.root.DesignerRootConfigLoader
+import pl.touk.nussknacker.ui.configloader.{ProcessingTypeConfigsLoader, ProcessingTypeConfigsLoaderFactory}
import pl.touk.nussknacker.ui.db.DbRef
import pl.touk.nussknacker.ui.db.timeseries.questdb.QuestDbFEStatisticsRepository
-import pl.touk.nussknacker.ui.process.processingtype.loader._
+import pl.touk.nussknacker.ui.process.processingtype.loader.{
+ ProcessingTypeDataLoader,
+ ProcessingTypesConfigBasedProcessingTypeDataLoader
+}
import pl.touk.nussknacker.ui.server.{AkkaHttpBasedRouteProvider, NussknackerHttpServer}
+import pl.touk.nussknacker.ui.util.ActorSystemBasedExecutionContextWithIORuntime
+import sttp.client3.asynchttpclient.future.AsyncHttpClientFutureBackend
import java.time.Clock
+import scala.concurrent.ExecutionContext
class NussknackerAppFactory(
- loadableDesignerRootConfig: LoadableDesignerRootConfig,
- processingTypeDataLoader: ProcessingTypeDataLoader
+ designerRootConfigLoader: DesignerRootConfigLoader,
+ processingTypeConfigsLoaderFactory: ProcessingTypeConfigsLoaderFactory,
+ createProcessingTypeDataLoader: ProcessingTypeConfigsLoader => ProcessingTypeDataLoader
) extends LazyLogging {
def createApp(clock: Clock = Clock.systemUTC()): Resource[IO, Unit] = {
for {
- rootConfig <- Resource.eval(loadableDesignerRootConfig.loadDesignerRootConfig())
+ rootConfig <- Resource.eval(designerRootConfigLoader.loadDesignerRootConfig())
system <- createActorSystem(rootConfig.rawConfig)
- materializer = Materializer(system)
+ executionContextWithIORuntime = ActorSystemBasedExecutionContextWithIORuntime.createFrom(system)
+ sttpBackend <- createSttpBackend
+ processingTypeConfigsLoader = processingTypeConfigsLoaderFactory.create(
+ rootConfig,
+ sttpBackend,
+ executionContextWithIORuntime
+ )
+ processingTypeDataLoader = createProcessingTypeDataLoader(processingTypeConfigsLoader)
+ materializer = Materializer(system)
_ <- Resource.eval(IO(JavaClassVersionChecker.check()))
_ <- Resource.eval(IO(SLF4JBridgeHandlerRegistrar.register()))
metricsRegistry <- createGeneralPurposeMetricsRegistry()
@@ -36,12 +52,14 @@ class NussknackerAppFactory(
new AkkaHttpBasedRouteProvider(
db,
metricsRegistry,
+ sttpBackend,
processingTypeDataLoader,
feStatisticsRepository,
clock
)(
system,
- materializer
+ materializer,
+ executionContextWithIORuntime
),
system
)
@@ -51,6 +69,15 @@ class NussknackerAppFactory(
} yield ()
}
+ private def createSttpBackend = {
+ Resource
+ .make(
+ acquire = IO(AsyncHttpClientFutureBackend.usingConfigBuilder(identity))
+ )(
+ release = backend => IO.fromFuture(IO(backend.close()))
+ )
+ }
+
private def createActorSystem(config: ConfigWithUnresolvedVersion) = {
Resource
.make(
@@ -83,10 +110,14 @@ class NussknackerAppFactory(
object NussknackerAppFactory {
- def apply(loadableDesignerRootConfig: LoadableDesignerRootConfig): NussknackerAppFactory = {
- val loadableProcessingTypeConfig = LoadableProcessingTypeConfigsFactory.create(loadableDesignerRootConfig)
- val processingTypeDataLoader = new ProcessingTypesConfigBasedProcessingTypeDataLoader(loadableProcessingTypeConfig)
- new NussknackerAppFactory(loadableDesignerRootConfig, processingTypeDataLoader)
+ def apply(designerRootConfigLoader: DesignerRootConfigLoader): NussknackerAppFactory = {
+ val processingTypeConfigsLoaderFactory =
+ ProcessingTypeConfigsLoaderFactoryServiceLoader.loadService(designerRootConfigLoader)
+ new NussknackerAppFactory(
+ designerRootConfigLoader,
+ processingTypeConfigsLoaderFactory,
+ new ProcessingTypesConfigBasedProcessingTypeDataLoader(_)
+ )
}
}
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/LocalProcessingTypeDataLoader.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/LocalProcessingTypeDataLoader.scala
index 9daea794bc5..6423f4d3c48 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/LocalProcessingTypeDataLoader.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/LocalProcessingTypeDataLoader.scala
@@ -5,7 +5,7 @@ import com.typesafe.config.ConfigFactory
import pl.touk.nussknacker.engine._
import pl.touk.nussknacker.engine.api.process.ProcessingType
import pl.touk.nussknacker.engine.util.Implicits.RichScalaMap
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
+import pl.touk.nussknacker.ui.configloader.DesignerRootConfig
import pl.touk.nussknacker.ui.process.processingtype.loader.ProcessingTypeDataLoader.toValueWithRestriction
import pl.touk.nussknacker.ui.process.processingtype.provider.ProcessingTypeDataState
import pl.touk.nussknacker.ui.process.processingtype.{CombinedProcessingTypeData, ProcessingTypeData}
@@ -16,7 +16,6 @@ class LocalProcessingTypeDataLoader(
) extends ProcessingTypeDataLoader {
override def loadProcessingTypeData(
- rootConfigLoadedAtStart: DesignerRootConfig,
getModelDependencies: ProcessingType => ModelDependencies,
getDeploymentManagerDependencies: ProcessingType => DeploymentManagerDependencies
): IO[ProcessingTypeDataState[ProcessingTypeData, CombinedProcessingTypeData]] = IO {
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/ProcessingTypeDataLoader.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/ProcessingTypeDataLoader.scala
index 26531566343..b2b526fc02f 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/ProcessingTypeDataLoader.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/ProcessingTypeDataLoader.scala
@@ -3,7 +3,6 @@ package pl.touk.nussknacker.ui.process.processingtype.loader
import cats.effect.IO
import pl.touk.nussknacker.engine.api.process.ProcessingType
import pl.touk.nussknacker.engine.{DeploymentManagerDependencies, ModelDependencies}
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
import pl.touk.nussknacker.ui.process.processingtype.provider.ProcessingTypeDataState
import pl.touk.nussknacker.ui.process.processingtype.{
CombinedProcessingTypeData,
@@ -14,7 +13,6 @@ import pl.touk.nussknacker.ui.process.processingtype.{
trait ProcessingTypeDataLoader {
def loadProcessingTypeData(
- rootConfigLoadedAtStart: DesignerRootConfig,
getModelDependencies: ProcessingType => ModelDependencies,
getDeploymentManagerDependencies: ProcessingType => DeploymentManagerDependencies,
): IO[ProcessingTypeDataState[ProcessingTypeData, CombinedProcessingTypeData]]
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/ProcessingTypesConfigBasedProcessingTypeDataLoader.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/ProcessingTypesConfigBasedProcessingTypeDataLoader.scala
index 3067c4cfd57..e3ee1a24e2b 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/ProcessingTypesConfigBasedProcessingTypeDataLoader.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/process/processingtype/loader/ProcessingTypesConfigBasedProcessingTypeDataLoader.scala
@@ -6,21 +6,20 @@ import pl.touk.nussknacker.engine._
import pl.touk.nussknacker.engine.api.process.ProcessingType
import pl.touk.nussknacker.engine.util.Implicits.RichScalaMap
import pl.touk.nussknacker.engine.util.loader.ScalaServiceLoader
-import pl.touk.nussknacker.ui.loadableconfig.{DesignerRootConfig, LoadableProcessingTypeConfigs}
+import pl.touk.nussknacker.ui.configloader.ProcessingTypeConfigsLoader
import pl.touk.nussknacker.ui.process.processingtype._
import pl.touk.nussknacker.ui.process.processingtype.loader.ProcessingTypeDataLoader.toValueWithRestriction
import pl.touk.nussknacker.ui.process.processingtype.provider.ProcessingTypeDataState
-class ProcessingTypesConfigBasedProcessingTypeDataLoader(loadableProcessingTypeConfigs: LoadableProcessingTypeConfigs)
+class ProcessingTypesConfigBasedProcessingTypeDataLoader(processingTypeConfigsLoader: ProcessingTypeConfigsLoader)
extends ProcessingTypeDataLoader {
override def loadProcessingTypeData(
- designerRootConfig: DesignerRootConfig,
getModelDependencies: ProcessingType => ModelDependencies,
getDeploymentManagerDependencies: ProcessingType => DeploymentManagerDependencies,
): IO[ProcessingTypeDataState[ProcessingTypeData, CombinedProcessingTypeData]] = {
- loadableProcessingTypeConfigs
- .loadProcessingTypeConfigs(designerRootConfig)
+ processingTypeConfigsLoader
+ .loadProcessingTypeConfigs()
.map(
ProcessingTypesConfigBasedProcessingTypeDataLoader
.loadProcessingTypeData(_, getModelDependencies, getDeploymentManagerDependencies)
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/AkkaHttpBasedRouteProvider.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/AkkaHttpBasedRouteProvider.scala
index 12f4d166ccb..3538a3ab74b 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/AkkaHttpBasedRouteProvider.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/AkkaHttpBasedRouteProvider.scala
@@ -28,6 +28,7 @@ import pl.touk.nussknacker.ui.config.{
FeatureTogglesConfig,
UsageStatisticsReportsConfig
}
+import pl.touk.nussknacker.ui.configloader.DesignerRootConfig
import pl.touk.nussknacker.ui.db.DbRef
import pl.touk.nussknacker.ui.db.timeseries.FEStatisticsRepository
import pl.touk.nussknacker.ui.definition.component.{ComponentServiceProcessingTypeData, DefaultComponentService}
@@ -40,7 +41,6 @@ import pl.touk.nussknacker.ui.initialization.Initialization
import pl.touk.nussknacker.ui.initialization.Initialization.nussknackerUser
import pl.touk.nussknacker.ui.listener.ProcessChangeListenerLoader
import pl.touk.nussknacker.ui.listener.services.NussknackerServices
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
import pl.touk.nussknacker.ui.metrics.RepositoryGauges
import pl.touk.nussknacker.ui.migrations.{MigrationApiAdapterService, MigrationService}
import pl.touk.nussknacker.ui.notifications.{NotificationConfig, NotificationServiceImpl}
@@ -93,12 +93,11 @@ import pl.touk.nussknacker.ui.validation.{
UIProcessValidator
}
import sttp.client3.SttpBackend
-import sttp.client3.asynchttpclient.future.AsyncHttpClientFutureBackend
import java.time.Clock
import java.util.concurrent.atomic.AtomicReference
import java.util.function.Supplier
-import scala.concurrent.{ExecutionContext, Future}
+import scala.concurrent.Future
import scala.io.Source
import scala.util.Try
import scala.util.control.NonFatal
@@ -106,24 +105,25 @@ import scala.util.control.NonFatal
class AkkaHttpBasedRouteProvider(
dbRef: DbRef,
metricsRegistry: MetricRegistry,
+ sttpBackend: SttpBackend[Future, Any],
processingTypeDataLoader: ProcessingTypeDataLoader,
feStatisticsRepository: FEStatisticsRepository[Future],
designerClock: Clock
-)(implicit system: ActorSystem, materializer: Materializer)
- extends RouteProvider[Route]
+)(
+ implicit system: ActorSystem,
+ materializer: Materializer,
+ executionContextWithIORuntime: ExecutionContextWithIORuntime
+) extends RouteProvider[Route]
with Directives
with LazyLogging {
override def createRoute(rootConfig: DesignerRootConfig): Resource[IO, Route] = {
- implicit val executionContextWithIORuntime: ExecutionContextWithIORuntime =
- ActorSystemBasedExecutionContextWithIORuntime.createFrom(system)
import executionContextWithIORuntime.ioRuntime
+ val resolvedRootConfig = rootConfig.rawConfig.resolved
+ val environment = resolvedRootConfig.getString("environment")
+ val featureTogglesConfig = FeatureTogglesConfig.create(resolvedRootConfig)
+ logger.info(s"Designer config loaded: \nfeatureTogglesConfig: $featureTogglesConfig")
for {
- sttpBackend <- createSttpBackend()
- resolvedRootConfig = rootConfig.rawConfig.resolved
- environment = resolvedRootConfig.getString("environment")
- featureTogglesConfig = FeatureTogglesConfig.create(resolvedRootConfig)
- _ = logger.info(s"Designer config loaded: \nfeatureTogglesConfig: $featureTogglesConfig")
countsReporter <- createCountsReporter(featureTogglesConfig, environment, sttpBackend)
actionServiceSupplier = new DelayedInitActionServiceSupplier
additionalUIConfigProvider = createAdditionalUIConfigProvider(resolvedRootConfig, sttpBackend)
@@ -131,7 +131,6 @@ class AkkaHttpBasedRouteProvider(
scenarioActivityRepository = DbScenarioActivityRepository.create(dbRef, designerClock)
dbioRunner = DBIOActionRunner(dbRef)
processingTypeDataProvider <- prepareProcessingTypeDataReload(
- rootConfig,
additionalUIConfigProvider,
actionServiceSupplier,
scenarioActivityRepository,
@@ -620,15 +619,6 @@ class AkkaHttpBasedRouteProvider(
}
}
- private def createSttpBackend()(implicit executionContext: ExecutionContext) = {
- Resource
- .make(
- acquire = IO(AsyncHttpClientFutureBackend.usingConfigBuilder(identity))
- )(
- release = backend => IO.fromFuture(IO(backend.close()))
- )
- }
-
private def initMetrics(
metricsRegistry: MetricRegistry,
config: Config,
@@ -709,19 +699,17 @@ class AkkaHttpBasedRouteProvider(
}
private def prepareProcessingTypeDataReload(
- rootConfigLoadedAtStart: DesignerRootConfig,
additionalUIConfigProvider: AdditionalUIConfigProvider,
actionServiceProvider: Supplier[ActionService],
scenarioActivityRepository: ScenarioActivityRepository,
dbioActionRunner: DBIOActionRunner,
sttpBackend: SttpBackend[Future, Any],
featureTogglesConfig: FeatureTogglesConfig
- )(implicit executionContext: ExecutionContext): Resource[IO, ReloadableProcessingTypeDataProvider] = {
+ ): Resource[IO, ReloadableProcessingTypeDataProvider] = {
Resource
.make(
acquire = IO.pure {
val laodProcessingTypeDataIO = processingTypeDataLoader.loadProcessingTypeData(
- rootConfigLoadedAtStart,
getModelDependencies(
additionalUIConfigProvider,
_,
@@ -750,7 +738,7 @@ class AkkaHttpBasedRouteProvider(
dbioActionRunner: DBIOActionRunner,
sttpBackend: SttpBackend[Future, Any],
processingType: ProcessingType
- )(implicit executionContext: ExecutionContext) = {
+ ) = {
val additionalConfigsFromProvider = additionalUIConfigProvider.getAllForProcessingType(processingType)
DeploymentManagerDependencies(
DefaultProcessingTypeDeployedScenariosProvider(dbRef, processingType),
@@ -784,11 +772,7 @@ class AkkaHttpBasedRouteProvider(
)
}
- private def createProcessingTypeDataReload() = {}
-
- private def createAdditionalUIConfigProvider(config: Config, sttpBackend: SttpBackend[Future, Any])(
- implicit ec: ExecutionContext
- ) = {
+ private def createAdditionalUIConfigProvider(config: Config, sttpBackend: SttpBackend[Future, Any]) = {
val additionalUIConfigProviderFactory: AdditionalUIConfigProviderFactory = {
Multiplicity(
ScalaServiceLoader.load[AdditionalUIConfigProviderFactory](getClass.getClassLoader)
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/NussknackerHttpServer.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/NussknackerHttpServer.scala
index 6835989ed16..6476469f180 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/NussknackerHttpServer.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/NussknackerHttpServer.scala
@@ -10,7 +10,7 @@ import fr.davit.akka.http.metrics.core.{HttpMetricsRegistry, HttpMetricsSettings
import fr.davit.akka.http.metrics.dropwizard.{DropwizardRegistry, DropwizardSettings}
import io.dropwizard.metrics5.MetricRegistry
import pl.touk.nussknacker.engine.ConfigWithUnresolvedVersion
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
+import pl.touk.nussknacker.ui.configloader.DesignerRootConfig
import pl.touk.nussknacker.ui.security.ssl.{HttpsConnectionContextFactory, SslConfigParser}
import java.util.concurrent.atomic.AtomicReference
diff --git a/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/RouteProvider.scala b/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/RouteProvider.scala
index ec2c44a49d9..f7e2665e4f1 100644
--- a/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/RouteProvider.scala
+++ b/designer/server/src/main/scala/pl/touk/nussknacker/ui/server/RouteProvider.scala
@@ -2,7 +2,7 @@ package pl.touk.nussknacker.ui.server
import akka.http.scaladsl.server.Route
import cats.effect.{IO, Resource}
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
+import pl.touk.nussknacker.ui.configloader.DesignerRootConfig
trait RouteProvider[R <: Route] {
diff --git a/designer/server/src/test/scala/pl/touk/nussknacker/test/base/it/NuItTest.scala b/designer/server/src/test/scala/pl/touk/nussknacker/test/base/it/NuItTest.scala
index 2536e8f7755..420f0b761c6 100644
--- a/designer/server/src/test/scala/pl/touk/nussknacker/test/base/it/NuItTest.scala
+++ b/designer/server/src/test/scala/pl/touk/nussknacker/test/base/it/NuItTest.scala
@@ -8,9 +8,8 @@ import org.scalatest.{BeforeAndAfterAll, Suite}
import pl.touk.nussknacker.test.DefaultUniquePortProvider
import pl.touk.nussknacker.test.base.db.WithHsqlDbTesting
import pl.touk.nussknacker.test.config.WithDesignerConfig
-import pl.touk.nussknacker.ui.config.root.LoadableDesignerRootConfig
+import pl.touk.nussknacker.ui.config.root.DesignerRootConfigLoader
import pl.touk.nussknacker.ui.factory.NussknackerAppFactory
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
trait NuItTest extends WithHsqlDbTesting with DefaultUniquePortProvider with WithClock with BeforeAndAfterAll {
this: Suite with WithDesignerConfig =>
@@ -23,10 +22,8 @@ trait NuItTest extends WithHsqlDbTesting with DefaultUniquePortProvider with Wit
override protected def beforeAll(): Unit = {
super.beforeAll()
- val loadableDesignerConfig = LoadableDesignerRootConfig(
- IO.delay(DesignerRootConfig.from(adjustNuTestConfig()))
- )
- releaseAppResources = NussknackerAppFactory(loadableDesignerConfig)
+ val designerConfigLoader = DesignerRootConfigLoader.fromConfig(adjustNuTestConfig())
+ releaseAppResources = NussknackerAppFactory(designerConfigLoader)
.createApp(clock = clock)
.allocated
.unsafeRunSync()
diff --git a/designer/server/src/test/scala/pl/touk/nussknacker/test/base/it/NuResourcesTest.scala b/designer/server/src/test/scala/pl/touk/nussknacker/test/base/it/NuResourcesTest.scala
index 8439360a19c..ac25d9eb069 100644
--- a/designer/server/src/test/scala/pl/touk/nussknacker/test/base/it/NuResourcesTest.scala
+++ b/designer/server/src/test/scala/pl/touk/nussknacker/test/base/it/NuResourcesTest.scala
@@ -39,7 +39,7 @@ import pl.touk.nussknacker.test.utils.scalas.AkkaHttpExtensions.toRequestEntity
import pl.touk.nussknacker.ui.api._
import pl.touk.nussknacker.ui.config.scenariotoolbar.CategoriesScenarioToolbarsConfigParser
import pl.touk.nussknacker.ui.config.FeatureTogglesConfig
-import pl.touk.nussknacker.ui.loadableconfig.{DesignerRootConfig, LoadableProcessingTypeConfigs}
+import pl.touk.nussknacker.ui.configloader.{DesignerRootConfig, ProcessingTypeConfigsLoader}
import pl.touk.nussknacker.ui.process.ProcessService.{CreateScenarioCommand, UpdateScenarioCommand}
import pl.touk.nussknacker.ui.process._
import pl.touk.nussknacker.ui.process.deployment._
@@ -146,7 +146,7 @@ trait NuResourcesTest
protected val typeToConfig: ProcessingTypeDataProvider[ProcessingTypeData, CombinedProcessingTypeData] = {
val rootConfig = DesignerRootConfig.from(testConfig)
- val processingTypeConfigs = LoadableProcessingTypeConfigs.extractProcessingTypeConfigs(rootConfig)
+ val processingTypeConfigs = ProcessingTypeConfigsLoader.extractProcessingTypeConfigs(rootConfig)
ProcessingTypeDataProvider(
ProcessingTypesConfigBasedProcessingTypeDataLoader
.loadProcessingTypeData(processingTypeConfigs, _ => modelDependencies, _ => deploymentManagerDependencies)
diff --git a/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/NussknackerHttpServerSpec.scala b/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/NussknackerHttpServerSpec.scala
index 46ecb8dac4d..ed97b0eb9ae 100644
--- a/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/NussknackerHttpServerSpec.scala
+++ b/designer/server/src/test/scala/pl/touk/nussknacker/ui/api/NussknackerHttpServerSpec.scala
@@ -11,7 +11,7 @@ import org.scalatest.matchers.should.Matchers
import pl.touk.nussknacker.test.config.ConfigWithScalaVersion
import pl.touk.nussknacker.test.utils.scalas.CatsTestExtensions._
import pl.touk.nussknacker.test.{DefaultUniquePortProvider, WithTestHttpClientCreator}
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
+import pl.touk.nussknacker.ui.configloader.DesignerRootConfig
import pl.touk.nussknacker.ui.security.ssl.HttpsConnectionContextFactory.prepareSSLContext
import pl.touk.nussknacker.ui.security.ssl.KeyStoreConfig
import pl.touk.nussknacker.ui.server.{NussknackerHttpServer, RouteProvider}
diff --git a/designer/server/src/test/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigLoadableProcessingTypeConfigsSpec.scala b/designer/server/src/test/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigProcessingTypeConfigsLoaderSpec.scala
similarity index 70%
rename from designer/server/src/test/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigLoadableProcessingTypeConfigsSpec.scala
rename to designer/server/src/test/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigProcessingTypeConfigsLoaderSpec.scala
index c1f14a81421..b536eb078dd 100644
--- a/designer/server/src/test/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigLoadableProcessingTypeConfigsSpec.scala
+++ b/designer/server/src/test/scala/pl/touk/nussknacker/ui/config/processingtype/EachTimeLoadingRootConfigProcessingTypeConfigsLoaderSpec.scala
@@ -6,10 +6,10 @@ import com.typesafe
import com.typesafe.config.{Config, ConfigFactory}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers.{convertToAnyShouldWrapper, include}
-import pl.touk.nussknacker.ui.config.root.LoadableDesignerRootConfig
-import pl.touk.nussknacker.ui.loadableconfig.{DesignerRootConfig, LoadableProcessingTypeConfigs}
+import pl.touk.nussknacker.ui.config.root.DesignerRootConfigLoader
+import pl.touk.nussknacker.ui.configloader.{DesignerRootConfig, ProcessingTypeConfigsLoader}
-class EachTimeLoadingRootConfigLoadableProcessingTypeConfigsSpec extends AnyFunSuite {
+class EachTimeLoadingRootConfigProcessingTypeConfigsLoaderSpec extends AnyFunSuite {
test("should throw when required configuration is missing") {
val config = ConfigFactory
@@ -32,8 +32,8 @@ class EachTimeLoadingRootConfigLoadableProcessingTypeConfigsSpec extends AnyFunS
.resolve()
intercept[typesafe.config.ConfigException] {
- staticConfigBasedLoadableProcessingTypeConfigs(config)
- .loadProcessingTypeConfigs(DesignerRootConfig.from(ConfigFactory.empty()))
+ staticConfigBasedProcessingTypeConfigsLoader(config)
+ .loadProcessingTypeConfigs()
.unsafeRunSync()
}.getMessage should include("No configuration setting found for key 'deploymentConfig.type'")
}
@@ -48,14 +48,14 @@ class EachTimeLoadingRootConfigLoadableProcessingTypeConfigsSpec extends AnyFunS
.resolve()
intercept[RuntimeException] {
- staticConfigBasedLoadableProcessingTypeConfigs(config)
- .loadProcessingTypeConfigs(DesignerRootConfig.from(ConfigFactory.empty()))
+ staticConfigBasedProcessingTypeConfigsLoader(config)
+ .loadProcessingTypeConfigs()
.unsafeRunSync()
}.getMessage should include("No scenario types configuration provided")
}
test("should load the second config when reloaded") {
- val loadableProcessingTypeConfigs = loadDifferentConfigPerInvocationLoadableProcessingTypeConfigs(
+ val processingTypeConfigsLoader = loadDifferentConfigPerInvocationProcessingTypeConfigsLoader(
config1 = ConfigFactory
.parseString(
"""
@@ -104,30 +104,30 @@ class EachTimeLoadingRootConfigLoadableProcessingTypeConfigsSpec extends AnyFunS
.resolve()
)
- val processingTypes1 = loadableProcessingTypeConfigs
- .loadProcessingTypeConfigs(DesignerRootConfig.from(ConfigFactory.empty()))
+ val processingTypes1 = processingTypeConfigsLoader
+ .loadProcessingTypeConfigs()
.unsafeRunSync()
processingTypes1.keys.toSet shouldBe Set("streaming")
- val processingTypes2 = loadableProcessingTypeConfigs
- .loadProcessingTypeConfigs(DesignerRootConfig.from(ConfigFactory.empty()))
+ val processingTypes2 = processingTypeConfigsLoader
+ .loadProcessingTypeConfigs()
.unsafeRunSync()
processingTypes2.keys.toSet shouldBe Set("streaming", "streaming2")
}
- private def staticConfigBasedLoadableProcessingTypeConfigs(config: Config): LoadableProcessingTypeConfigs = {
- new EachTimeLoadingRootConfigLoadableProcessingTypeConfigs(
- LoadableDesignerRootConfig(IO.pure(DesignerRootConfig.from(config)))
+ private def staticConfigBasedProcessingTypeConfigsLoader(config: Config): ProcessingTypeConfigsLoader = {
+ new EachTimeLoadingRootConfigProcessingTypeConfigsLoader(
+ DesignerRootConfigLoader.fromConfig(config)
)
}
- private def loadDifferentConfigPerInvocationLoadableProcessingTypeConfigs(
+ private def loadDifferentConfigPerInvocationProcessingTypeConfigsLoader(
config1: Config,
config2: Config,
configs: Config*
- ): LoadableProcessingTypeConfigs = {
+ ): ProcessingTypeConfigsLoader = {
val ref = Ref.unsafe[IO, Int](0)
val allConfigs = config1 :: config2 :: configs.toList
val loadConfig = ref.getAndUpdate(_ + 1).flatMap { idx =>
@@ -136,9 +136,7 @@ class EachTimeLoadingRootConfigLoadableProcessingTypeConfigsSpec extends AnyFunS
case None => IO.raiseError(throw new IllegalStateException(s"Cannot load the config more than [$idx]"))
}
}
- new EachTimeLoadingRootConfigLoadableProcessingTypeConfigs(
- LoadableDesignerRootConfig(loadConfig)
- )
+ new EachTimeLoadingRootConfigProcessingTypeConfigsLoader(() => loadConfig)
}
}
diff --git a/designer/server/src/test/scala/pl/touk/nussknacker/ui/integration/ConfigurationTest.scala b/designer/server/src/test/scala/pl/touk/nussknacker/ui/config/root/ConfigurationTest.scala
similarity index 92%
rename from designer/server/src/test/scala/pl/touk/nussknacker/ui/integration/ConfigurationTest.scala
rename to designer/server/src/test/scala/pl/touk/nussknacker/ui/config/root/ConfigurationTest.scala
index c7aedc2fc88..6ef7bb497e6 100644
--- a/designer/server/src/test/scala/pl/touk/nussknacker/ui/integration/ConfigurationTest.scala
+++ b/designer/server/src/test/scala/pl/touk/nussknacker/ui/config/root/ConfigurationTest.scala
@@ -1,13 +1,13 @@
-package pl.touk.nussknacker.ui.integration
+package pl.touk.nussknacker.ui.config.root
+import cats.effect.unsafe.implicits.global
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
import pl.touk.nussknacker.engine.util.config.ConfigFactoryExt
import pl.touk.nussknacker.engine.{ModelData, ProcessingTypeConfig}
import pl.touk.nussknacker.test.config.ConfigWithScalaVersion
import pl.touk.nussknacker.test.utils.domain.TestFactory
-import pl.touk.nussknacker.ui.config.root.DesignerRootConfigLoader
-import cats.effect.unsafe.implicits.global
+
import java.net.URI
import java.nio.file.Files
import java.util.UUID
@@ -29,8 +29,8 @@ class ConfigurationTest extends AnyFunSuite with Matchers {
}
test("defaultConfig works") {
- DesignerRootConfigLoader
- .load(globalConfig, classLoader)
+ new DesignerRootConfigLoaderImpl(classLoader)
+ .load(globalConfig)
.unsafeRunSync()
.resolved
.getString("db.driver") shouldBe "org.hsqldb.jdbc.JDBCDriver"
@@ -39,8 +39,8 @@ class ConfigurationTest extends AnyFunSuite with Matchers {
test("should be possible to config entries defined in default ui config from passed config") {
val configUri = writeToTemp("foo: ${storageDir}") // storageDir is defined inside defaultDesignerConfig.conf
- val loadedConfig = DesignerRootConfigLoader
- .load(ConfigFactoryExt.parseConfigFallbackChain(List(configUri), classLoader), classLoader)
+ val loadedConfig = new DesignerRootConfigLoaderImpl(classLoader)
+ .load(ConfigFactoryExt.parseConfigFallbackChain(List(configUri), classLoader))
.unsafeRunSync()
loadedConfig.resolved.getString("foo") shouldEqual "./storage"
@@ -81,8 +81,8 @@ class ConfigurationTest extends AnyFunSuite with Matchers {
val result =
try {
System.setProperty(randomPropertyName, "I win!")
- DesignerRootConfigLoader
- .load(ConfigFactoryExt.parseConfigFallbackChain(List(conf1), classLoader), classLoader)
+ new DesignerRootConfigLoaderImpl(classLoader)
+ .load(ConfigFactoryExt.parseConfigFallbackChain(List(conf1), classLoader))
.unsafeRunSync()
} finally {
System.getProperties.remove(randomPropertyName)
diff --git a/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/processingtype/ProcessingTypeDataProviderSpec.scala b/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/processingtype/ProcessingTypeDataProviderSpec.scala
index e87bb5a4570..f4a8e88d82d 100644
--- a/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/processingtype/ProcessingTypeDataProviderSpec.scala
+++ b/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/processingtype/ProcessingTypeDataProviderSpec.scala
@@ -10,7 +10,6 @@ import pl.touk.nussknacker.engine.testing.{DeploymentManagerProviderStub, LocalM
import pl.touk.nussknacker.security.Permission
import pl.touk.nussknacker.test.utils.domain.TestFactory
import pl.touk.nussknacker.ui.UnauthorizedError
-import pl.touk.nussknacker.ui.loadableconfig.DesignerRootConfig
import pl.touk.nussknacker.ui.process.processingtype.loader.LocalProcessingTypeDataLoader
import pl.touk.nussknacker.ui.process.processingtype.provider.ProcessingTypeDataProvider
import pl.touk.nussknacker.ui.security.api.RealLoggedUser
@@ -57,7 +56,6 @@ class ProcessingTypeDataProviderSpec extends AnyFunSuite with Matchers {
)
loader
.loadProcessingTypeData(
- DesignerRootConfig.from(ConfigFactory.empty()),
_ => modelDependencies,
_ => TestFactory.deploymentManagerDependencies
)
diff --git a/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/processingtype/ScenarioParametersServiceTest.scala b/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/processingtype/ScenarioParametersServiceTest.scala
index ffb93c919db..dfa1cdd8c6d 100644
--- a/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/processingtype/ScenarioParametersServiceTest.scala
+++ b/designer/server/src/test/scala/pl/touk/nussknacker/ui/process/processingtype/ScenarioParametersServiceTest.scala
@@ -16,7 +16,7 @@ import pl.touk.nussknacker.restmodel.scenariodetails.ScenarioParameters
import pl.touk.nussknacker.security.Permission
import pl.touk.nussknacker.test.ValidatedValuesDetailedMessage
import pl.touk.nussknacker.test.utils.domain.TestFactory
-import pl.touk.nussknacker.ui.loadableconfig.{DesignerRootConfig, LoadableProcessingTypeConfigs}
+import pl.touk.nussknacker.ui.configloader.{DesignerRootConfig, ProcessingTypeConfigsLoader}
import pl.touk.nussknacker.ui.process.processingtype.loader.ProcessingTypesConfigBasedProcessingTypeDataLoader
import pl.touk.nussknacker.ui.security.api.{LoggedUser, RealLoggedUser}
@@ -280,7 +280,7 @@ class ScenarioParametersServiceTest
val workPath = designerServerModuleDir.resolve("work")
logDirectoryStructure(workPath)
- val processingTypeConfigs = LoadableProcessingTypeConfigs.extractProcessingTypeConfigs(
+ val processingTypeConfigs = ProcessingTypeConfigsLoader.extractProcessingTypeConfigs(
DesignerRootConfig.from(ConfigFactory.parseFile(devApplicationConfFile).withFallback(fallbackConfig))
)
val processingTypeData = ProcessingTypesConfigBasedProcessingTypeDataLoader