From 5af18affdb268012809b91527bec44bed08216ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Wed, 12 Jun 2024 08:07:08 +0200 Subject: [PATCH] refactor: Introduce InfrastructureModule --- .../org/knora/webapi/core/LayersTest.scala | 4 +++ .../org/knora/webapi/core/LayersLive.scala | 3 +++ .../webapi/slice/admin/AdminModule.scala | 10 +++++++- .../admin/domain/AdminDomainModule.scala | 10 ++++++-- .../slice/admin/repo/AdminRepoModule.scala | 16 +++++++++--- .../infrastructure/InfrastructureModule.scala | 25 +++++++++++++++++++ 6 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 webapi/src/main/scala/org/knora/webapi/slice/infrastructure/InfrastructureModule.scala diff --git a/integration/src/test/scala/org/knora/webapi/core/LayersTest.scala b/integration/src/test/scala/org/knora/webapi/core/LayersTest.scala index 8a71a787a9..cee23e8ae7 100644 --- a/integration/src/test/scala/org/knora/webapi/core/LayersTest.scala +++ b/integration/src/test/scala/org/knora/webapi/core/LayersTest.scala @@ -43,6 +43,8 @@ import org.knora.webapi.slice.admin.domain.service.* import org.knora.webapi.slice.admin.domain.service.ProjectExportStorageService import org.knora.webapi.slice.common.api.* import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper +import org.knora.webapi.slice.infrastructure.CacheManager +import org.knora.webapi.slice.infrastructure.InfrastructureModule import org.knora.webapi.slice.infrastructure.JwtService import org.knora.webapi.slice.infrastructure.JwtServiceLive import org.knora.webapi.slice.infrastructure.api.ManagementEndpoints @@ -105,6 +107,7 @@ object LayersTest { DspIngestClient & GravsearchTypeInspectionRunner & GroupRestService & + InfrastructureModule.Provided & InferenceOptimizationService & InvalidTokenCache & IriConverter & @@ -167,6 +170,7 @@ object LayersTest { ConstructResponseUtilV2Live.layer, DspIngestClientLive.layer, HandlerMapper.layer, + InfrastructureModule.layer, InferenceOptimizationService.layer, InvalidTokenCache.layer, IriConverter.layer, diff --git a/webapi/src/main/scala/org/knora/webapi/core/LayersLive.scala b/webapi/src/main/scala/org/knora/webapi/core/LayersLive.scala index 02092ee2ac..2ebc35246a 100644 --- a/webapi/src/main/scala/org/knora/webapi/core/LayersLive.scala +++ b/webapi/src/main/scala/org/knora/webapi/core/LayersLive.scala @@ -40,6 +40,7 @@ import org.knora.webapi.slice.admin.api.service.UserRestService import org.knora.webapi.slice.admin.domain.service.* import org.knora.webapi.slice.common.api.* import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper +import org.knora.webapi.slice.infrastructure.InfrastructureModule import org.knora.webapi.slice.infrastructure.JwtService import org.knora.webapi.slice.infrastructure.JwtServiceLive import org.knora.webapi.slice.infrastructure.api.ManagementEndpoints @@ -88,6 +89,7 @@ object LayersLive { GroupRestService & HttpServer & IIIFRequestMessageHandler & + InfrastructureModule.Provided & InstrumentationServerConfig & InvalidTokenCache & IriConverter & @@ -145,6 +147,7 @@ object LayersLive { HandlerMapper.layer, HttpServer.layer, IIIFRequestMessageHandlerLive.layer, + InfrastructureModule.layer, InvalidTokenCache.layer, IriConverter.layer, IriService.layer, diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/AdminModule.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/AdminModule.scala index 0f17db9e70..39f552e436 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/AdminModule.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/AdminModule.scala @@ -12,13 +12,21 @@ import org.knora.webapi.responders.IriService import org.knora.webapi.slice.admin.domain.AdminDomainModule import org.knora.webapi.slice.admin.repo.AdminRepoModule import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper +import org.knora.webapi.slice.infrastructure.CacheManager import org.knora.webapi.slice.ontology.domain.service.OntologyRepo import org.knora.webapi.store.triplestore.api.TriplestoreService object AdminModule { type Dependencies = - AppConfig & IriService & OntologyRepo & PredicateObjectMapper & TriplestoreService + // format: off + AppConfig & + CacheManager & + IriService & + OntologyRepo & + PredicateObjectMapper & + TriplestoreService + // format: on type Provided = AdminDomainModule.Provided diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/AdminDomainModule.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/AdminDomainModule.scala index 5c7d092f9c..b1fd372885 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/AdminDomainModule.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/AdminDomainModule.scala @@ -24,12 +24,18 @@ import org.knora.webapi.store.triplestore.api.TriplestoreService object AdminDomainModule { type Dependencies = - AppConfig & AdminRepoModule.Provided & IriService & OntologyRepo & TriplestoreService + // format: off + AdminRepoModule.Provided & + AppConfig & + CacheManager & + IriService & + OntologyRepo & + TriplestoreService + // format: on type Provided = // format: off AdministrativePermissionService & - CacheManager & GroupService & KnoraGroupService & KnoraProjectService & diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/repo/AdminRepoModule.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/repo/AdminRepoModule.scala index a1748acb20..88703a5071 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/repo/AdminRepoModule.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/repo/AdminRepoModule.scala @@ -20,11 +20,21 @@ import org.knora.webapi.store.triplestore.api.TriplestoreService object AdminRepoModule { - type Dependencies = TriplestoreService - type Provided = AdministrativePermissionRepo & CacheManager & KnoraGroupRepo & KnoraProjectRepo & KnoraUserRepo + type Dependencies = + // format: off + TriplestoreService & + CacheManager + // format: on + + type Provided = + // format: off + AdministrativePermissionRepo & + KnoraGroupRepo & + KnoraProjectRepo & + KnoraUserRepo + // format: on val layer = ZLayer.makeSome[Dependencies, Provided]( - CacheManager.layer, KnoraGroupRepoLive.layer, KnoraProjectRepoLive.layer, KnoraUserRepoLive.layer, diff --git a/webapi/src/main/scala/org/knora/webapi/slice/infrastructure/InfrastructureModule.scala b/webapi/src/main/scala/org/knora/webapi/slice/infrastructure/InfrastructureModule.scala new file mode 100644 index 0000000000..fdb7d81ef3 --- /dev/null +++ b/webapi/src/main/scala/org/knora/webapi/slice/infrastructure/InfrastructureModule.scala @@ -0,0 +1,25 @@ +/* + * Copyright © 2021 - 2024 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.knora.webapi.slice.infrastructure + +import zio.ZLayer + +object InfrastructureModule { + + type Dependencies = + // format: off + Any + // format: on + + type Provided = + // format: off + CacheManager + // format: on + + val layer = ZLayer.makeSome[Dependencies, Provided]( + CacheManager.layer, + ) +}