Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete Cats Effect 2 Migration #4488

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ val log4catsVersion = "1.7.0"
val logbackVersion = "1.4.11"
val magnoliaVersion = "1.1.6"
val mockitoVersion = "1.17.27"
val monixVersion = "3.4.1"
val monixBioVersion = "1.2.0"
val munitVersion = "1.0.0-M10"
val nimbusJoseJwtVersion = "9.37"
val postgresJdbcVersion = "42.6.0"
Expand Down Expand Up @@ -113,7 +111,6 @@ lazy val log4cats = "org.typelevel" %% "log4cats-slf4j"
lazy val logback = "ch.qos.logback" % "logback-classic" % logbackVersion
lazy val magnolia = "com.softwaremill.magnolia1_2" %% "magnolia" % magnoliaVersion
lazy val mockito = "org.mockito" %% "mockito-scala" % mockitoVersion
lazy val monixBio = "io.monix" %% "monix-bio" % monixBioVersion
lazy val munit = "org.scalameta" %% "munit" % munitVersion
lazy val nimbusJoseJwt = "com.nimbusds" % "nimbus-jose-jwt" % nimbusJoseJwtVersion
lazy val pureconfig = "com.github.pureconfig" %% "pureconfig" % pureconfigVersion
Expand Down Expand Up @@ -212,7 +209,6 @@ lazy val kernel = project
circeCore,
circeParser,
handleBars,
monixBio,
nimbusJoseJwt,
kamonCore,
log4cats,
Expand Down Expand Up @@ -242,7 +238,6 @@ lazy val testkit = project
),
catsRetry,
doobiePostgres,
monixBio,
munit,
scalaTest,
testContainers
Expand All @@ -267,7 +262,6 @@ lazy val sourcingPsql = project
distageCore,
fs2,
fs2io,
monixBio,
munit % Test,
catsEffectLaws % Test,
logback % Test
Expand Down Expand Up @@ -295,7 +289,6 @@ lazy val rdf = project
jenaArq,
jsonldjava,
magnolia,
monixBio,
topBraidShacl,
akkaSlf4j % Test,
akkaTestKit % Test,
Expand Down Expand Up @@ -325,7 +318,6 @@ lazy val sdk = project
circeGenericExtras,
distageCore,
fs2,
monixBio,
akkaTestKitTyped % Test,
akkaHttpTestKit % Test,
munit % Test,
Expand Down Expand Up @@ -804,7 +796,6 @@ lazy val tests = project
circeGenericExtras,
fs2,
logback,
monixBio,
scalaLogging,
akkaTestKit % Test,
akkaHttpTestKit % Test,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.{Directive1, Route}
import cats.effect.IO
import cats.implicits._
import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder.JsonLdEncoder
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.routes.OrganizationsRoutes.OrganizationInput
import ch.epfl.bluebrain.nexus.delta.sdk.OrganizationResource
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._
import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._
import ch.epfl.bluebrain.nexus.delta.sdk.directives.{AuthDirectives, DeltaSchemeDirectives}
import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
Expand Down Expand Up @@ -71,7 +70,7 @@ final class OrganizationsRoutes(
createdBy,
updatedBy,
label,
org => aclCheck.authorizeFor(org.label, orgs.read, allAcls).toUIO
org => aclCheck.authorizeFor(org.label, orgs.read, allAcls)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import akka.http.scaladsl.server._
import cats.data.OptionT
import cats.effect.{ContextShift, IO}
import cats.implicits._
import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder.JsonLdEncoder
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.sdk._
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._
import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._
import ch.epfl.bluebrain.nexus.delta.sdk.directives.{AuthDirectives, DeltaSchemeDirectives}
import ch.epfl.bluebrain.nexus.delta.sdk.fusion.FusionConfig
import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities
Expand Down Expand Up @@ -75,7 +74,7 @@ final class ProjectsRoutes(
createdBy,
updatedBy,
label,
proj => aclCheck.authorizeFor(proj.ref, projectsPermissions.read, allAcls).toUIO
proj => aclCheck.authorizeFor(proj.ref, projectsPermissions.read, allAcls)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server._
import cats.effect.IO
import cats.syntax.all._
import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._
import ch.epfl.bluebrain.nexus.delta.rdf.RdfError
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.schemas
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution}
Expand All @@ -14,8 +13,8 @@ import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.routes.ResourcesRoutes.asSourceWithMetadata
import ch.epfl.bluebrain.nexus.delta.sdk._
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._
import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._
import ch.epfl.bluebrain.nexus.delta.sdk.directives.{AuthDirectives, DeltaSchemeDirectives}
import ch.epfl.bluebrain.nexus.delta.sdk.fusion.FusionConfig
import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities
Expand All @@ -28,7 +27,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.resources.NexusSource.DecodingOption
import ch.epfl.bluebrain.nexus.delta.sdk.resources.model.ResourceRejection.{InvalidJsonLdFormat, InvalidSchemaRejection, NoSchemaProvided, ResourceNotFound}
import ch.epfl.bluebrain.nexus.delta.sdk.resources.model.{Resource, ResourceRejection}
import ch.epfl.bluebrain.nexus.delta.sdk.resources.{NexusSource, Resources}
import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef
import io.circe.{Json, Printer}

/**
Expand Down Expand Up @@ -68,9 +66,6 @@ final class ResourcesRoutes(
implicit private def resourceFAJsonLdEncoder[A: JsonLdEncoder]: JsonLdEncoder[ResourceF[A]] =
ResourceF.resourceFAJsonLdEncoder(ContextValue.empty)

private def indexUIO(project: ProjectRef, resource: ResourceF[Resource], mode: IndexingMode) =
index(project, resource, mode).toUIO

def routes: Route =
baseUriPrefix(baseUri.prefix) {
pathPrefix("resources") {
Expand All @@ -85,7 +80,7 @@ final class ResourcesRoutes(
Created,
resources
.create(project, resourceSchema, source.value, tag)
.flatTap(indexUIO(project, _, mode))
.flatTap(index(project, _, mode))
.map(_.void)
.attemptNarrow[ResourceRejection]
)
Expand All @@ -102,7 +97,7 @@ final class ResourcesRoutes(
Created,
resources
.create(project, schema, source.value, tag)
.flatTap(indexUIO(project, _, mode))
.flatTap(index(project, _, mode))
.map(_.void)
.attemptNarrow[ResourceRejection]
.rejectWhen(wrongJsonOrNotFound)
Expand All @@ -124,7 +119,7 @@ final class ResourcesRoutes(
Created,
resources
.create(resource, project, schema, source.value, tag)
.flatTap(indexUIO(project, _, mode))
.flatTap(index(project, _, mode))
.map(_.void)
.attemptNarrow[ResourceRejection]
.rejectWhen(wrongJsonOrNotFound)
Expand All @@ -134,7 +129,7 @@ final class ResourcesRoutes(
emit(
resources
.update(resource, project, schemaOpt, rev, source.value, tag)
.flatTap(indexUIO(project, _, mode))
.flatTap(index(project, _, mode))
.map(_.void)
.attemptNarrow[ResourceRejection]
.rejectWhen(wrongJsonOrNotFound)
Expand All @@ -148,7 +143,7 @@ final class ResourcesRoutes(
emit(
resources
.deprecate(resource, project, schemaOpt, rev)
.flatTap(indexUIO(project, _, mode))
.flatTap(index(project, _, mode))
.map(_.void)
.attemptNarrow[ResourceRejection]
.rejectWhen(wrongJsonOrNotFound)
Expand Down Expand Up @@ -178,7 +173,7 @@ final class ResourcesRoutes(
emit(
resources
.undeprecate(resource, project, schemaOpt, rev)
.flatTap(indexUIO(project, _, mode))
.flatTap(index(project, _, mode))
.map(_.void)
.attemptNarrow[ResourceRejection]
.rejectWhen(wrongJsonOrNotFound)
Expand All @@ -193,7 +188,7 @@ final class ResourcesRoutes(
.flatMap { schema =>
resources
.updateAttachedSchema(resource, project, schema)
.flatTap(indexUIO(project, _, mode))
.flatTap(index(project, _, mode))
}
.attemptNarrow[ResourceRejection]
.rejectWhen(wrongJsonOrNotFound)
Expand All @@ -207,7 +202,7 @@ final class ResourcesRoutes(
OK,
resources
.refresh(resource, project, schemaOpt)
.flatTap(indexUIO(project, _, mode))
.flatTap(index(project, _, mode))
.map(_.void)
.attemptNarrow[ResourceRejection]
.rejectWhen(wrongJsonOrNotFound)
Expand Down Expand Up @@ -273,7 +268,7 @@ final class ResourcesRoutes(
Created,
resources
.tag(resource, project, schemaOpt, tag, tagRev, rev)
.flatTap(indexUIO(project, _, mode))
.flatTap(index(project, _, mode))
.map(_.void)
.attemptNarrow[ResourceRejection]
.rejectWhen(wrongJsonOrNotFound)
Expand All @@ -289,7 +284,7 @@ final class ResourcesRoutes(
emit(
resources
.deleteTag(resource, project, schemaOpt, tag, rev)
.flatTap(indexUIO(project, _, mode))
.flatTap(index(project, _, mode))
.map(_.void)
.attemptNarrow[ResourceRejection]
.rejectOn[ResourceNotFound]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.routes
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration.MigrateEffectSyntax
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck
import ch.epfl.bluebrain.nexus.delta.sdk.acls.model.AclAddress
import ch.epfl.bluebrain.nexus.delta.sdk.circe.CirceUnmarshalling
Expand All @@ -26,8 +25,7 @@ import ch.epfl.bluebrain.nexus.delta.sdk.permissions.model.Permission
final class UserPermissionsRoutes(identities: Identities, aclCheck: AclCheck, storages: StoragePermissionProvider)(
implicit baseUri: BaseUri
) extends AuthDirectives(identities, aclCheck)
with CirceUnmarshalling
with MigrateEffectSyntax {
with CirceUnmarshalling {

def routes: Route =
baseUriPrefix(baseUri.prefix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.permissions.{Permissions, StoragePermis
import ch.epfl.bluebrain.nexus.delta.sdk.sse.SseEncoder
import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors
import izumi.distage.model.definition.{Id, ModuleDef}
import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._

/**
* Acls module wiring config.
Expand All @@ -37,7 +36,7 @@ object AclsModule extends ModuleDef {
timer: Timer[IO]
) =>
acls.AclsImpl(
permissions.fetchPermissionSet.toUIO,
permissions.fetchPermissionSet,
AclsImpl.findUnknownRealms(xas),
permissions.minimum,
config.acls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.config.{DatabaseConfig, Projection
import ch.megard.akka.http.cors.scaladsl.settings.CorsSettings
import com.typesafe.config.Config
import izumi.distage.model.definition.{Id, ModuleDef}
import monix.bio.UIO
import org.slf4j.{Logger, LoggerFactory}

import scala.concurrent.duration.DurationInt
Expand Down Expand Up @@ -106,7 +105,6 @@ class DeltaModule(appCfg: AppConfig, config: Config)(implicit classLoader: Class
new JsonLdJavaApi(appCfg.jsonLdApi)(contextShift)
}

make[Clock[UIO]].from(Clock[UIO])
make[Clock[IO]].from(Clock.create[IO])
make[UUIDF].from(UUIDF.random)
make[JsonKeyOrdering].from(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ch.epfl.bluebrain.nexus.delta.wiring
import cats.effect.{ContextShift, IO, Timer}
import ch.epfl.bluebrain.nexus.delta.Main.pluginsMaxPriority
import ch.epfl.bluebrain.nexus.delta.config.AppConfig
import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.routes.{ElemRoutes, EventsRoutes}
Expand All @@ -13,7 +12,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaSchemeDirectives
import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities
import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri
import ch.epfl.bluebrain.nexus.delta.sdk.organizations.Organizations
import ch.epfl.bluebrain.nexus.delta.sdk.organizations.model.OrganizationRejection
import ch.epfl.bluebrain.nexus.delta.sdk.projects.Projects
import ch.epfl.bluebrain.nexus.delta.sdk.sse.{SseElemStream, SseEncoder, SseEventLog}
import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors
Expand All @@ -37,7 +35,7 @@ object EventsModule extends ModuleDef {
) =>
SseEventLog(
sseEncoders,
organizations.fetch(_).void.toBIO[OrganizationRejection],
organizations.fetch(_).void,
projects.fetch(_).map { p => (p.value.organizationUuid, p.value.uuid) },
config.sse,
xas
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ch.epfl.bluebrain.nexus.delta.wiring

import ch.epfl.bluebrain.nexus.delta.Main.pluginsMaxPriority
import ch.epfl.bluebrain.nexus.delta.kernel.effect.migration._
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.routes.MultiFetchRoutes
Expand All @@ -23,7 +22,7 @@ object MultiFetchModule extends ModuleDef {
) =>
MultiFetch(
aclCheck,
(input: MultiFetchRequest.Input) => shifts.fetch(input.id, input.project).toUIO
(input: MultiFetchRequest.Input) => shifts.fetch(input.id, input.project)
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ch.epfl.bluebrain.nexus.delta.config

import ch.epfl.bluebrain.nexus.delta.kernel.utils.CatsEffectsClasspathResourceUtils
import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceUtils
import ch.epfl.bluebrain.nexus.testkit.scalatest.ce.CatsEffectSpec
import com.typesafe.config.impl.ConfigImpl
import org.scalatest.BeforeAndAfterAll
Expand All @@ -26,7 +26,7 @@ class AppConfigSpec extends CatsEffectSpec with BeforeAndAfterAll {

"AppConfig" should {

val externalConfigPath = CatsEffectsClasspathResourceUtils.absolutePath("/config/external.conf").accepted
val externalConfigPath = ClasspathResourceUtils.absolutePath("/config/external.conf").accepted

"load conf" in {
val (conf, _) = AppConfig.load().accepted
Expand Down
Loading