From cb5dec6b19049d239b2ab989bd19ac8151be64ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Tue, 24 Oct 2023 10:32:43 +0200 Subject: [PATCH] refactor: Remove/Fix some compiler warnings (#2899) --- .../webapi/core/InstrumentationServer.scala | 55 +++++++++---------- .../admin/ProjectsServiceLiveSpec.scala | 3 - 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/webapi/src/main/scala/org/knora/webapi/core/InstrumentationServer.scala b/webapi/src/main/scala/org/knora/webapi/core/InstrumentationServer.scala index 2f4afb05ea..771e049881 100644 --- a/webapi/src/main/scala/org/knora/webapi/core/InstrumentationServer.scala +++ b/webapi/src/main/scala/org/knora/webapi/core/InstrumentationServer.scala @@ -20,36 +20,33 @@ object InstrumentationServer { private val instrumentationServer = for { - index <- ZIO.service[IndexApp].map(_.route) - health <- ZIO.service[HealthRouteZ].map(_.route) - prometheus <- ZIO.service[PrometheusApp].map(_.route) + index <- ZIO.serviceWith[IndexApp](_.route) + health <- ZIO.serviceWith[HealthRouteZ](_.route) + prometheus <- ZIO.serviceWith[PrometheusApp](_.route) app = index ++ health ++ prometheus - _ <- Server.serve(app) + _ <- Server.serve(app).forkDaemon } yield () - val make: ZIO[State with AppConfig, Throwable, Fiber.Runtime[Throwable, Unit]] = - ZIO - .service[AppConfig] - .flatMap { config => - val port = config.instrumentationServerConfig.port - val interval = config.instrumentationServerConfig.interval - val metricsConfig = MetricsConfig(interval) - ZIO.logInfo(s"Starting instrumentation http server on port: $port") *> - instrumentationServer - .provideSome[State]( - // HTTP Server - Server.defaultWithPort(port), - // HTTP routes - IndexApp.layer, - HealthRouteZ.layer, - PrometheusApp.layer, - // Metrics dependencies - prometheus.publisherLayer, - ZLayer.succeed(metricsConfig) >>> prometheus.prometheusLayer, - Runtime.enableRuntimeMetrics, - Runtime.enableFiberRoots, - DefaultJvmMetrics.live.unit - ) - .forkDaemon - } + val make: ZIO[State with AppConfig, Throwable, Unit] = + ZIO.serviceWithZIO[AppConfig] { config => + val port = config.instrumentationServerConfig.port + val interval = config.instrumentationServerConfig.interval + val metricsConfig = MetricsConfig(interval) + ZIO.logInfo(s"Starting instrumentation http server on port: $port") *> + instrumentationServer + .provideSome[State]( + // HTTP Server + Server.defaultWithPort(port), + // HTTP routes + IndexApp.layer, + HealthRouteZ.layer, + PrometheusApp.layer, + // Metrics dependencies + prometheus.publisherLayer, + ZLayer.succeed(metricsConfig) >>> prometheus.prometheusLayer, + Runtime.enableRuntimeMetrics, + Runtime.enableFiberRoots, + DefaultJvmMetrics.live.unit + ) + } } diff --git a/webapi/src/test/scala/org/knora/webapi/responders/admin/ProjectsServiceLiveSpec.scala b/webapi/src/test/scala/org/knora/webapi/responders/admin/ProjectsServiceLiveSpec.scala index e72460cf69..052b1ae262 100644 --- a/webapi/src/test/scala/org/knora/webapi/responders/admin/ProjectsServiceLiveSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/responders/admin/ProjectsServiceLiveSpec.scala @@ -25,7 +25,6 @@ import org.knora.webapi.slice.admin.domain.service.DspIngestClientMock import org.knora.webapi.slice.admin.domain.service.ProjectExportServiceStub import org.knora.webapi.slice.admin.domain.service.ProjectExportStorageServiceLive import org.knora.webapi.slice.admin.domain.service.ProjectImportServiceLive -import org.knora.webapi.store.triplestore.impl.TriplestoreServiceLive object ProjectsServiceLiveSpec extends ZIOSpecDefault { @@ -62,8 +61,6 @@ object ProjectsServiceLiveSpec extends ZIOSpecDefault { private def projectServiceLayer(exp: Expectation[ProjectsResponderADM]): ULayer[ProjectADMRestService] = ZLayer.make[ProjectADMRestService]( - TriplestoreServiceLive.layer, - StringFormatter.test, ProjectsADMRestServiceLive.layer, exp.toLayer, org.knora.webapi.slice.common.api.RestPermissionServiceLive.layer,