From 8f3d3ed359ec56b51e52420f8d3799ba84c5fa6e Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 13 Jul 2022 14:08:43 +0000 Subject: [PATCH 1/5] Applied Scalafix rule(s) github:typelevel/cats-effect/v3_0_0?sha=v3.0.0 --- .../scala/com/azavea/franklin/api/Server.scala | 3 ++- .../azavea/franklin/api/ServerOptions.scala | 2 +- .../api/services/CollectionItemsService.scala | 3 ++- .../api/services/CollectionsService.scala | 4 ++-- .../api/services/LandingPageService.scala | 3 ++- .../franklin/api/services/SearchService.scala | 3 ++- .../franklin/api/services/TileService.scala | 3 ++- .../azavea/franklin/commands/Commands.scala | 18 ++++++++---------- .../franklin/commands/DatabaseConfig.scala | 6 ++---- .../franklin/commands/DatabaseOptions.scala | 2 +- .../com/azavea/franklin/crawler/StacIO.scala | 4 ++-- .../franklin/crawler/StacItemImporter.scala | 2 +- .../com/azavea/franklin/database/Config.scala | 2 +- .../database/MosaicDefinitionDao.scala | 1 - .../extensions/validation/package.scala | 2 +- .../azavea/franklin/api/TestImplicits.scala | 2 +- .../com/azavea/franklin/api/TestServices.scala | 5 +++-- .../franklin/database/SetupTemplateDB.scala | 5 +++-- 18 files changed, 36 insertions(+), 34 deletions(-) diff --git a/application/src/main/scala/com/azavea/franklin/api/Server.scala b/application/src/main/scala/com/azavea/franklin/api/Server.scala index 8089371fb..d9dfca7e3 100644 --- a/application/src/main/scala/com/azavea/franklin/api/Server.scala +++ b/application/src/main/scala/com/azavea/franklin/api/Server.scala @@ -38,6 +38,7 @@ import scala.concurrent.ExecutionContext import java.util.concurrent.Executors import java.util.concurrent.TimeUnit +import cats.effect.Resource object Server extends IOApp.WithContext { @@ -153,7 +154,7 @@ $$$$ logger ).withLogging(true) ).orNotFound - serverBuilderBlocker <- Blocker[IO] + serverBuilderBlocker <- Resource.unit[IO] server <- { BlazeServerBuilder[IO](serverBuilderBlocker.blockingContext) .bindHttp(apiConfig.internalPort.value, "0.0.0.0") diff --git a/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala b/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala index db70ebbc7..9d9be3515 100644 --- a/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala +++ b/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala @@ -1,6 +1,6 @@ package com.azavea.franklin.api -import cats.effect.{ContextShift, Sync} +import cats.effect.Sync import io.circe.{CursorOp, DecodingFailure} import sttp.tapir.DecodeResult import sttp.tapir.server.http4s.Http4sServerOptions diff --git a/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala b/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala index ae84a52bb..a6ed90e72 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala @@ -40,6 +40,7 @@ import sttp.tapir.server.http4s._ import java.net.URLDecoder import java.nio.charset.StandardCharsets +import cats.effect.Temporal class CollectionItemsService[F[_]: Concurrent]( xa: Transactor[F], @@ -48,7 +49,7 @@ class CollectionItemsService[F[_]: Concurrent]( rootLink: StacLink )( implicit contextShift: ContextShift[F], - timer: Timer[F], + timer: Temporal[F], serverOptions: Http4sServerOptions[F], backend: SttpBackend[F, Nothing, NothingT], logger: Logger[F] diff --git a/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala b/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala index f0539521c..1cf6512b8 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala @@ -2,7 +2,6 @@ package com.azavea.franklin.api.services import cats.data.EitherT import cats.effect._ -import cats.effect.concurrent.Ref import cats.syntax.all._ import com.azavea.franklin.api.commands.ApiConfig import com.azavea.franklin.api.endpoints.CollectionEndpoints @@ -30,6 +29,7 @@ import sttp.tapir.server.http4s._ import java.net.URLDecoder import java.nio.charset.StandardCharsets import java.util.UUID +import cats.effect.Temporal class CollectionsService[F[_]: Concurrent]( xa: Transactor[F], @@ -37,7 +37,7 @@ class CollectionsService[F[_]: Concurrent]( collectionExtensionsRef: ExtensionRef[F, StacCollection] )( implicit contextShift: ContextShift[F], - timer: Timer[F], + timer: Temporal[F], serverOptions: Http4sServerOptions[F], backend: SttpBackend[F, Nothing, NothingT], logger: Logger[F] diff --git a/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala b/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala index 5d5010da9..195bd2f74 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala @@ -20,10 +20,11 @@ import io.circe.syntax._ import org.http4s._ import org.http4s.dsl.Http4sDsl import sttp.tapir.server.http4s._ +import cats.effect.Temporal class LandingPageService[F[_]: Concurrent](apiConfig: ApiConfig)( implicit contextShift: ContextShift[F], - timer: Timer[F], + timer: Temporal[F], serverOptions: Http4sServerOptions[F] ) extends Http4sDsl[F] { diff --git a/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala b/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala index 0b30ec92e..375064b7c 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala @@ -18,6 +18,7 @@ import io.circe.syntax._ import org.http4s._ import org.http4s.dsl.Http4sDsl import sttp.tapir.server.http4s._ +import cats.effect.Temporal class SearchService[F[_]: Concurrent]( apiConfig: ApiConfig, @@ -27,7 +28,7 @@ class SearchService[F[_]: Concurrent]( rootLink: StacLink )( implicit contextShift: ContextShift[F], - timerF: Timer[F], + timerF: Temporal[F], serverOptions: Http4sServerOptions[F] ) extends Http4sDsl[F] { diff --git a/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala b/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala index 7867b3d46..8d80970a2 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala @@ -50,8 +50,9 @@ import scala.concurrent.duration._ import java.net.URLDecoder import java.nio.charset.StandardCharsets import java.util.UUID +import cats.effect.Temporal -class TileService[F[_]: Async: Concurrent: Parallel: Logger: Timer: ContextShift]( +class TileService[F[_]: Async: Concurrent: Parallel: Logger: Temporal: ContextShift]( serverHost: NonEmptyString, enableTiles: Boolean, path: Option[String], diff --git a/application/src/main/scala/com/azavea/franklin/commands/Commands.scala b/application/src/main/scala/com/azavea/franklin/commands/Commands.scala index 3552bf140..5d7dcdcf2 100644 --- a/application/src/main/scala/com/azavea/franklin/commands/Commands.scala +++ b/application/src/main/scala/com/azavea/franklin/commands/Commands.scala @@ -2,7 +2,7 @@ package com.azavea.franklin.api.commands import cats.data.NonEmptyList import cats.effect.Sync -import cats.effect.{ContextShift, ExitCode, IO} +import cats.effect.{ExitCode, IO} import cats.syntax.all._ import com.azavea.franklin.crawler.CatalogStacImport import com.azavea.franklin.crawler.StacItemImporter @@ -34,15 +34,13 @@ object Commands { ) private def runItemsImportOpts( - implicit sync: Sync[IO], - cs: ContextShift[IO] - ): Opts[RunItemsImport] = + implicit sync: Sync[IO]): Opts[RunItemsImport] = Opts.subcommand("import-items", "Import STAC items into an existing collection") { (Options.collectionID, Options.stacItems(sync), Options.databaseConfig, Options.dryRun) .mapN(RunItemsImport) } - private def runCatalogImportOpts(implicit cs: ContextShift[IO]): Opts[RunCatalogImport] = + private def runCatalogImportOpts: Opts[RunCatalogImport] = Opts.subcommand("import-catalog", "Import a STAC catalog") { ( Options.catalogRoot, @@ -51,12 +49,12 @@ object Commands { ).mapN(RunCatalogImport) } - private def runMigrationsOpts(implicit cs: ContextShift[IO]): Opts[RunMigrations] = + private def runMigrationsOpts: Opts[RunMigrations] = Opts.subcommand("migrate", "Runs migrations against database") { Options.databaseConfig map RunMigrations } - private def runServerOpts(implicit cs: ContextShift[IO]): Opts[RunServer] = + private def runServerOpts: Opts[RunServer] = Opts.subcommand("serve", "Runs web service") { (Options.apiConfig, Options.databaseConfig) mapN RunServer } @@ -78,7 +76,7 @@ object Commands { itemUris: NonEmptyList[String], config: DatabaseConfig, dryRun: Boolean - )(implicit cs: ContextShift[IO], backend: SttpBackend[IO, Nothing, NothingT]) = { + )(implicit backend: SttpBackend[IO, Nothing, NothingT]) = { val xa = config.getTransactor(dryRun) new StacItemImporter(collectionId, itemUris).runIO(xa) } @@ -88,14 +86,14 @@ object Commands { config: DatabaseConfig, dryRun: Boolean )( - implicit contextShift: ContextShift[IO], + implicit backend: SttpBackend[IO, Nothing, NothingT] ): IO[Unit] = { val xa = config.getTransactor(dryRun) new CatalogStacImport(stacCatalog).runIO(xa) } - def applicationCommand(implicit cs: ContextShift[IO]): Command[Product] = + def applicationCommand: Command[Product] = Command("", "Your Friendly Neighborhood OGC API - Features and STAC Web Service") { runServerOpts orElse runMigrationsOpts orElse runCatalogImportOpts orElse runItemsImportOpts } diff --git a/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala b/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala index faeebf3bf..3bc3091c7 100644 --- a/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala +++ b/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala @@ -1,8 +1,6 @@ package com.azavea.franklin.api.commands import cats.effect.Async -import cats.effect.Blocker -import cats.effect.ContextShift import cats.effect.IO import cats.effect.Resource import com.zaxxer.hikari.HikariConfig @@ -36,7 +34,7 @@ case object DatabaseConfig { ) extends DatabaseConfig { val jdbcUrl = s"jdbc:postgresql://$dbHost:$dbPort/$dbName" - def getTransactor(dryRun: Boolean)(implicit contextShift: ContextShift[IO]) = { + def getTransactor(dryRun: Boolean) = { Transactor.strategy.set( Transactor.fromDriverManager[IO]( driver, @@ -64,7 +62,7 @@ case object DatabaseConfig { jdbcUrl: String ) extends DatabaseConfig { - def getTransactor(dryRun: Boolean)(implicit contextShift: ContextShift[IO]): Transactor[IO] = { + def getTransactor(dryRun: Boolean): Transactor[IO] = { val blockingEc = ExecutionContext.fromExecutor( Executors.newCachedThreadPool( new ThreadFactory { diff --git a/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala b/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala index 2840d7de3..a3457b6f3 100644 --- a/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala +++ b/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala @@ -53,7 +53,7 @@ trait DatabaseOptions { help = databaseConnectionStringHelp ) orElse Opts.env[String]("DB_CONNECTION_STRING", help = databaseConnectionStringHelp) - def databaseConfig(implicit contextShift: ContextShift[IO]): Opts[DatabaseConfig] = + def databaseConfig: Opts[DatabaseConfig] = ((connectionString map { DatabaseConfig.FromConnectionString }) orElse ( databaseUser, databasePassword, diff --git a/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala b/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala index a6ec1c91a..0613d28a4 100644 --- a/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala +++ b/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala @@ -1,7 +1,7 @@ package com.azavea.franklin.crawler import cats.data.{NonEmptyList, Validated, ValidatedNel} -import cats.effect.{ContextShift, IO} +import cats.effect.IO import cats.syntax.all._ import com.amazonaws.services.s3.AmazonS3ClientBuilder import com.azavea.stac4s.{`application/json`, StacCollection, StacItem, StacLink, StacLinkType} @@ -148,7 +148,7 @@ object StacIO { rewriteSourceIfPresent: Boolean, inCollectionId: Option[String] )( - implicit contextShift: ContextShift[IO], + implicit logger: Logger[IO], backend: SttpBackend[IO, Nothing, NothingT] ): IO[StacItem] = { diff --git a/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala b/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala index 5dec3bc59..f1d8d28b0 100644 --- a/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala +++ b/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala @@ -2,7 +2,7 @@ package com.azavea.franklin.crawler import cats.data.EitherT import cats.data.NonEmptyList -import cats.effect.{ContextShift, IO} +import cats.effect.IO import cats.syntax.all._ import com.azavea.franklin.database.{getItemsBulkExtent, StacCollectionDao, StacItemDao} import com.azavea.stac4s._ diff --git a/application/src/main/scala/com/azavea/franklin/database/Config.scala b/application/src/main/scala/com/azavea/franklin/database/Config.scala index 0fac8aa63..58d007c0d 100644 --- a/application/src/main/scala/com/azavea/franklin/database/Config.scala +++ b/application/src/main/scala/com/azavea/franklin/database/Config.scala @@ -29,7 +29,7 @@ object DatabaseConfig { val dbMaximumPoolSize: Int = Properties.envOrElse("POSTGRES_DB_POOL_SIZE", "5").toInt - def nonHikariTransactor[F[_]: Async](databaseName: String)(implicit cs: ContextShift[F]) = { + def nonHikariTransactor[F[_]: Async](databaseName: String) = { Transactor.fromDriverManager[F]( "org.postgresql.Driver", jdbcNoDBUrl + databaseName, diff --git a/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala b/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala index f524539ff..9ea2febbf 100644 --- a/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala +++ b/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala @@ -2,7 +2,6 @@ package com.azavea.franklin.database import cats.data.NonEmptyList import cats.data.OptionT -import cats.effect.ContextShift import cats.effect.IO import cats.effect.LiftIO import cats.syntax.applicative._ diff --git a/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala b/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala index 834fd9584..9d577483b 100644 --- a/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala +++ b/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala @@ -3,7 +3,6 @@ package com.azavea.franklin.extensions import cats.Functor import cats.data.NonEmptyList import cats.effect.Sync -import cats.effect.concurrent.Ref import cats.syntax.all._ import com.azavea.franklin.extensions.validation.syntax._ import com.azavea.stac4s.StacCollection @@ -28,6 +27,7 @@ import sttp.client.circe._ import sttp.model.{Uri => SttpUri} import scala.util.{Failure, Success, Try} +import cats.effect.Ref package object validation { diff --git a/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala b/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala index ab1bded6f..5a28a969c 100644 --- a/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala +++ b/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala @@ -1,7 +1,7 @@ package com.azavea.franklin.api import cats.Applicative -import cats.effect.{Concurrent, ContextShift, Timer} +import cats.effect.Concurrent import cats.syntax.functor._ import com.azavea.franklin.api.commands.ApiConfig import com.azavea.franklin.api.services.{CollectionItemsService, CollectionsService, SearchService} diff --git a/application/src/test/scala/com/azavea/franklin/api/TestServices.scala b/application/src/test/scala/com/azavea/franklin/api/TestServices.scala index 8d98e0207..4be04d56f 100644 --- a/application/src/test/scala/com/azavea/franklin/api/TestServices.scala +++ b/application/src/test/scala/com/azavea/franklin/api/TestServices.scala @@ -1,7 +1,7 @@ package com.azavea.franklin.api import cats.Applicative -import cats.effect.{Concurrent, ContextShift, Timer} +import cats.effect.Concurrent import cats.syntax.functor._ import com.azavea.franklin.api.commands.ApiConfig import com.azavea.franklin.api.services.{CollectionItemsService, CollectionsService, SearchService} @@ -11,10 +11,11 @@ import doobie.Transactor import eu.timepit.refined.types.numeric.{NonNegInt, PosInt} import io.chrisdavenport.log4cats.noop.NoOpLogger import sttp.client.asynchttpclient.cats.AsyncHttpClientCatsBackend +import cats.effect.Temporal class TestServices[F[_]: Concurrent](xa: Transactor[F])( implicit cs: ContextShift[F], - timer: Timer[F] + timer: Temporal[F] ) extends TestImplicits[F] { val rootLink = StacLink( diff --git a/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala b/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala index fc5dc6dce..9de824b06 100644 --- a/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala +++ b/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala @@ -1,6 +1,6 @@ package com.azavea.franklin.database -import cats.effect.{ContextShift, IO, Timer} +import cats.effect.IO import cats.syntax.all._ import doobie._ import doobie.free.connection.unit @@ -11,6 +11,7 @@ import org.specs2._ import org.specs2.specification.{AfterAll, BeforeAll} import scala.concurrent.ExecutionContext.Implicits.global +import cats.effect.Temporal object SetupTemplateDB { val templateDbName: String = "testing_template" @@ -56,7 +57,7 @@ trait TestDatabaseSpec extends Specification with BeforeAll with AfterAll { implicit val cs: ContextShift[IO] = IO.contextShift(global) - implicit val timer: Timer[IO] = IO.timer(global) + implicit val timer: Temporal[IO] = IO.timer(global) // Transactor used by tests with rollback behavior and transactions def transactor: Transactor[IO] = DatabaseConfig.nonHikariTransactor[IO](dbName) From 88f3ee062399638b025d31419095cce8e83662c3 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 13 Jul 2022 14:10:59 +0000 Subject: [PATCH 2/5] Update cats-effect to 3.3.14 --- project/Versions.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Versions.scala b/project/Versions.scala index 4be1cfdf0..57438f583 100644 --- a/project/Versions.scala +++ b/project/Versions.scala @@ -7,7 +7,7 @@ object Versions { // which is the same as that in the GeoTrellis // https://github.com/locationtech/geotrellis/blob/v3.6.0/project/Dependencies.scala#L86 val AWSSdk2Version = "2.16.13" - val CatsEffectVersion = "2.5.5" + val CatsEffectVersion = "3.3.14" val CatsScalacheckVersion = "0.3.1" val CatsVersion = "2.8.0" val CirceFs2Version = "0.14.2" From 6f6b4531e7413b77b1c712ac74f89f505f157129 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 17 Sep 2022 13:22:21 +0000 Subject: [PATCH 3/5] Revert commit(s) 88f3ee0, 8f3d3ed --- .../scala/com/azavea/franklin/api/Server.scala | 3 +-- .../azavea/franklin/api/ServerOptions.scala | 2 +- .../api/services/CollectionItemsService.scala | 3 +-- .../api/services/CollectionsService.scala | 4 ++-- .../api/services/LandingPageService.scala | 3 +-- .../franklin/api/services/SearchService.scala | 3 +-- .../franklin/api/services/TileService.scala | 3 +-- .../azavea/franklin/commands/Commands.scala | 18 ++++++++++-------- .../franklin/commands/DatabaseConfig.scala | 6 ++++-- .../franklin/commands/DatabaseOptions.scala | 2 +- .../com/azavea/franklin/crawler/StacIO.scala | 4 ++-- .../franklin/crawler/StacItemImporter.scala | 2 +- .../com/azavea/franklin/database/Config.scala | 2 +- .../database/MosaicDefinitionDao.scala | 1 + .../extensions/validation/package.scala | 2 +- .../azavea/franklin/api/TestImplicits.scala | 2 +- .../com/azavea/franklin/api/TestServices.scala | 5 ++--- .../franklin/database/SetupTemplateDB.scala | 5 ++--- project/Versions.scala | 2 +- 19 files changed, 35 insertions(+), 37 deletions(-) diff --git a/application/src/main/scala/com/azavea/franklin/api/Server.scala b/application/src/main/scala/com/azavea/franklin/api/Server.scala index d9dfca7e3..8089371fb 100644 --- a/application/src/main/scala/com/azavea/franklin/api/Server.scala +++ b/application/src/main/scala/com/azavea/franklin/api/Server.scala @@ -38,7 +38,6 @@ import scala.concurrent.ExecutionContext import java.util.concurrent.Executors import java.util.concurrent.TimeUnit -import cats.effect.Resource object Server extends IOApp.WithContext { @@ -154,7 +153,7 @@ $$$$ logger ).withLogging(true) ).orNotFound - serverBuilderBlocker <- Resource.unit[IO] + serverBuilderBlocker <- Blocker[IO] server <- { BlazeServerBuilder[IO](serverBuilderBlocker.blockingContext) .bindHttp(apiConfig.internalPort.value, "0.0.0.0") diff --git a/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala b/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala index 9d9be3515..db70ebbc7 100644 --- a/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala +++ b/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala @@ -1,6 +1,6 @@ package com.azavea.franklin.api -import cats.effect.Sync +import cats.effect.{ContextShift, Sync} import io.circe.{CursorOp, DecodingFailure} import sttp.tapir.DecodeResult import sttp.tapir.server.http4s.Http4sServerOptions diff --git a/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala b/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala index a6ed90e72..ae84a52bb 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala @@ -40,7 +40,6 @@ import sttp.tapir.server.http4s._ import java.net.URLDecoder import java.nio.charset.StandardCharsets -import cats.effect.Temporal class CollectionItemsService[F[_]: Concurrent]( xa: Transactor[F], @@ -49,7 +48,7 @@ class CollectionItemsService[F[_]: Concurrent]( rootLink: StacLink )( implicit contextShift: ContextShift[F], - timer: Temporal[F], + timer: Timer[F], serverOptions: Http4sServerOptions[F], backend: SttpBackend[F, Nothing, NothingT], logger: Logger[F] diff --git a/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala b/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala index 1cf6512b8..f0539521c 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala @@ -2,6 +2,7 @@ package com.azavea.franklin.api.services import cats.data.EitherT import cats.effect._ +import cats.effect.concurrent.Ref import cats.syntax.all._ import com.azavea.franklin.api.commands.ApiConfig import com.azavea.franklin.api.endpoints.CollectionEndpoints @@ -29,7 +30,6 @@ import sttp.tapir.server.http4s._ import java.net.URLDecoder import java.nio.charset.StandardCharsets import java.util.UUID -import cats.effect.Temporal class CollectionsService[F[_]: Concurrent]( xa: Transactor[F], @@ -37,7 +37,7 @@ class CollectionsService[F[_]: Concurrent]( collectionExtensionsRef: ExtensionRef[F, StacCollection] )( implicit contextShift: ContextShift[F], - timer: Temporal[F], + timer: Timer[F], serverOptions: Http4sServerOptions[F], backend: SttpBackend[F, Nothing, NothingT], logger: Logger[F] diff --git a/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala b/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala index 195bd2f74..5d5010da9 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala @@ -20,11 +20,10 @@ import io.circe.syntax._ import org.http4s._ import org.http4s.dsl.Http4sDsl import sttp.tapir.server.http4s._ -import cats.effect.Temporal class LandingPageService[F[_]: Concurrent](apiConfig: ApiConfig)( implicit contextShift: ContextShift[F], - timer: Temporal[F], + timer: Timer[F], serverOptions: Http4sServerOptions[F] ) extends Http4sDsl[F] { diff --git a/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala b/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala index 375064b7c..0b30ec92e 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala @@ -18,7 +18,6 @@ import io.circe.syntax._ import org.http4s._ import org.http4s.dsl.Http4sDsl import sttp.tapir.server.http4s._ -import cats.effect.Temporal class SearchService[F[_]: Concurrent]( apiConfig: ApiConfig, @@ -28,7 +27,7 @@ class SearchService[F[_]: Concurrent]( rootLink: StacLink )( implicit contextShift: ContextShift[F], - timerF: Temporal[F], + timerF: Timer[F], serverOptions: Http4sServerOptions[F] ) extends Http4sDsl[F] { diff --git a/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala b/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala index 8d80970a2..7867b3d46 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala @@ -50,9 +50,8 @@ import scala.concurrent.duration._ import java.net.URLDecoder import java.nio.charset.StandardCharsets import java.util.UUID -import cats.effect.Temporal -class TileService[F[_]: Async: Concurrent: Parallel: Logger: Temporal: ContextShift]( +class TileService[F[_]: Async: Concurrent: Parallel: Logger: Timer: ContextShift]( serverHost: NonEmptyString, enableTiles: Boolean, path: Option[String], diff --git a/application/src/main/scala/com/azavea/franklin/commands/Commands.scala b/application/src/main/scala/com/azavea/franklin/commands/Commands.scala index 5d7dcdcf2..3552bf140 100644 --- a/application/src/main/scala/com/azavea/franklin/commands/Commands.scala +++ b/application/src/main/scala/com/azavea/franklin/commands/Commands.scala @@ -2,7 +2,7 @@ package com.azavea.franklin.api.commands import cats.data.NonEmptyList import cats.effect.Sync -import cats.effect.{ExitCode, IO} +import cats.effect.{ContextShift, ExitCode, IO} import cats.syntax.all._ import com.azavea.franklin.crawler.CatalogStacImport import com.azavea.franklin.crawler.StacItemImporter @@ -34,13 +34,15 @@ object Commands { ) private def runItemsImportOpts( - implicit sync: Sync[IO]): Opts[RunItemsImport] = + implicit sync: Sync[IO], + cs: ContextShift[IO] + ): Opts[RunItemsImport] = Opts.subcommand("import-items", "Import STAC items into an existing collection") { (Options.collectionID, Options.stacItems(sync), Options.databaseConfig, Options.dryRun) .mapN(RunItemsImport) } - private def runCatalogImportOpts: Opts[RunCatalogImport] = + private def runCatalogImportOpts(implicit cs: ContextShift[IO]): Opts[RunCatalogImport] = Opts.subcommand("import-catalog", "Import a STAC catalog") { ( Options.catalogRoot, @@ -49,12 +51,12 @@ object Commands { ).mapN(RunCatalogImport) } - private def runMigrationsOpts: Opts[RunMigrations] = + private def runMigrationsOpts(implicit cs: ContextShift[IO]): Opts[RunMigrations] = Opts.subcommand("migrate", "Runs migrations against database") { Options.databaseConfig map RunMigrations } - private def runServerOpts: Opts[RunServer] = + private def runServerOpts(implicit cs: ContextShift[IO]): Opts[RunServer] = Opts.subcommand("serve", "Runs web service") { (Options.apiConfig, Options.databaseConfig) mapN RunServer } @@ -76,7 +78,7 @@ object Commands { itemUris: NonEmptyList[String], config: DatabaseConfig, dryRun: Boolean - )(implicit backend: SttpBackend[IO, Nothing, NothingT]) = { + )(implicit cs: ContextShift[IO], backend: SttpBackend[IO, Nothing, NothingT]) = { val xa = config.getTransactor(dryRun) new StacItemImporter(collectionId, itemUris).runIO(xa) } @@ -86,14 +88,14 @@ object Commands { config: DatabaseConfig, dryRun: Boolean )( - implicit + implicit contextShift: ContextShift[IO], backend: SttpBackend[IO, Nothing, NothingT] ): IO[Unit] = { val xa = config.getTransactor(dryRun) new CatalogStacImport(stacCatalog).runIO(xa) } - def applicationCommand: Command[Product] = + def applicationCommand(implicit cs: ContextShift[IO]): Command[Product] = Command("", "Your Friendly Neighborhood OGC API - Features and STAC Web Service") { runServerOpts orElse runMigrationsOpts orElse runCatalogImportOpts orElse runItemsImportOpts } diff --git a/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala b/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala index 3bc3091c7..faeebf3bf 100644 --- a/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala +++ b/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala @@ -1,6 +1,8 @@ package com.azavea.franklin.api.commands import cats.effect.Async +import cats.effect.Blocker +import cats.effect.ContextShift import cats.effect.IO import cats.effect.Resource import com.zaxxer.hikari.HikariConfig @@ -34,7 +36,7 @@ case object DatabaseConfig { ) extends DatabaseConfig { val jdbcUrl = s"jdbc:postgresql://$dbHost:$dbPort/$dbName" - def getTransactor(dryRun: Boolean) = { + def getTransactor(dryRun: Boolean)(implicit contextShift: ContextShift[IO]) = { Transactor.strategy.set( Transactor.fromDriverManager[IO]( driver, @@ -62,7 +64,7 @@ case object DatabaseConfig { jdbcUrl: String ) extends DatabaseConfig { - def getTransactor(dryRun: Boolean): Transactor[IO] = { + def getTransactor(dryRun: Boolean)(implicit contextShift: ContextShift[IO]): Transactor[IO] = { val blockingEc = ExecutionContext.fromExecutor( Executors.newCachedThreadPool( new ThreadFactory { diff --git a/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala b/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala index a3457b6f3..2840d7de3 100644 --- a/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala +++ b/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala @@ -53,7 +53,7 @@ trait DatabaseOptions { help = databaseConnectionStringHelp ) orElse Opts.env[String]("DB_CONNECTION_STRING", help = databaseConnectionStringHelp) - def databaseConfig: Opts[DatabaseConfig] = + def databaseConfig(implicit contextShift: ContextShift[IO]): Opts[DatabaseConfig] = ((connectionString map { DatabaseConfig.FromConnectionString }) orElse ( databaseUser, databasePassword, diff --git a/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala b/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala index 0613d28a4..a6ec1c91a 100644 --- a/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala +++ b/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala @@ -1,7 +1,7 @@ package com.azavea.franklin.crawler import cats.data.{NonEmptyList, Validated, ValidatedNel} -import cats.effect.IO +import cats.effect.{ContextShift, IO} import cats.syntax.all._ import com.amazonaws.services.s3.AmazonS3ClientBuilder import com.azavea.stac4s.{`application/json`, StacCollection, StacItem, StacLink, StacLinkType} @@ -148,7 +148,7 @@ object StacIO { rewriteSourceIfPresent: Boolean, inCollectionId: Option[String] )( - implicit + implicit contextShift: ContextShift[IO], logger: Logger[IO], backend: SttpBackend[IO, Nothing, NothingT] ): IO[StacItem] = { diff --git a/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala b/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala index f1d8d28b0..5dec3bc59 100644 --- a/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala +++ b/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala @@ -2,7 +2,7 @@ package com.azavea.franklin.crawler import cats.data.EitherT import cats.data.NonEmptyList -import cats.effect.IO +import cats.effect.{ContextShift, IO} import cats.syntax.all._ import com.azavea.franklin.database.{getItemsBulkExtent, StacCollectionDao, StacItemDao} import com.azavea.stac4s._ diff --git a/application/src/main/scala/com/azavea/franklin/database/Config.scala b/application/src/main/scala/com/azavea/franklin/database/Config.scala index 58d007c0d..0fac8aa63 100644 --- a/application/src/main/scala/com/azavea/franklin/database/Config.scala +++ b/application/src/main/scala/com/azavea/franklin/database/Config.scala @@ -29,7 +29,7 @@ object DatabaseConfig { val dbMaximumPoolSize: Int = Properties.envOrElse("POSTGRES_DB_POOL_SIZE", "5").toInt - def nonHikariTransactor[F[_]: Async](databaseName: String) = { + def nonHikariTransactor[F[_]: Async](databaseName: String)(implicit cs: ContextShift[F]) = { Transactor.fromDriverManager[F]( "org.postgresql.Driver", jdbcNoDBUrl + databaseName, diff --git a/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala b/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala index 9ea2febbf..f524539ff 100644 --- a/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala +++ b/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala @@ -2,6 +2,7 @@ package com.azavea.franklin.database import cats.data.NonEmptyList import cats.data.OptionT +import cats.effect.ContextShift import cats.effect.IO import cats.effect.LiftIO import cats.syntax.applicative._ diff --git a/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala b/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala index 9d577483b..834fd9584 100644 --- a/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala +++ b/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala @@ -3,6 +3,7 @@ package com.azavea.franklin.extensions import cats.Functor import cats.data.NonEmptyList import cats.effect.Sync +import cats.effect.concurrent.Ref import cats.syntax.all._ import com.azavea.franklin.extensions.validation.syntax._ import com.azavea.stac4s.StacCollection @@ -27,7 +28,6 @@ import sttp.client.circe._ import sttp.model.{Uri => SttpUri} import scala.util.{Failure, Success, Try} -import cats.effect.Ref package object validation { diff --git a/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala b/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala index 5a28a969c..ab1bded6f 100644 --- a/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala +++ b/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala @@ -1,7 +1,7 @@ package com.azavea.franklin.api import cats.Applicative -import cats.effect.Concurrent +import cats.effect.{Concurrent, ContextShift, Timer} import cats.syntax.functor._ import com.azavea.franklin.api.commands.ApiConfig import com.azavea.franklin.api.services.{CollectionItemsService, CollectionsService, SearchService} diff --git a/application/src/test/scala/com/azavea/franklin/api/TestServices.scala b/application/src/test/scala/com/azavea/franklin/api/TestServices.scala index 4be04d56f..8d98e0207 100644 --- a/application/src/test/scala/com/azavea/franklin/api/TestServices.scala +++ b/application/src/test/scala/com/azavea/franklin/api/TestServices.scala @@ -1,7 +1,7 @@ package com.azavea.franklin.api import cats.Applicative -import cats.effect.Concurrent +import cats.effect.{Concurrent, ContextShift, Timer} import cats.syntax.functor._ import com.azavea.franklin.api.commands.ApiConfig import com.azavea.franklin.api.services.{CollectionItemsService, CollectionsService, SearchService} @@ -11,11 +11,10 @@ import doobie.Transactor import eu.timepit.refined.types.numeric.{NonNegInt, PosInt} import io.chrisdavenport.log4cats.noop.NoOpLogger import sttp.client.asynchttpclient.cats.AsyncHttpClientCatsBackend -import cats.effect.Temporal class TestServices[F[_]: Concurrent](xa: Transactor[F])( implicit cs: ContextShift[F], - timer: Temporal[F] + timer: Timer[F] ) extends TestImplicits[F] { val rootLink = StacLink( diff --git a/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala b/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala index 9de824b06..fc5dc6dce 100644 --- a/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala +++ b/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala @@ -1,6 +1,6 @@ package com.azavea.franklin.database -import cats.effect.IO +import cats.effect.{ContextShift, IO, Timer} import cats.syntax.all._ import doobie._ import doobie.free.connection.unit @@ -11,7 +11,6 @@ import org.specs2._ import org.specs2.specification.{AfterAll, BeforeAll} import scala.concurrent.ExecutionContext.Implicits.global -import cats.effect.Temporal object SetupTemplateDB { val templateDbName: String = "testing_template" @@ -57,7 +56,7 @@ trait TestDatabaseSpec extends Specification with BeforeAll with AfterAll { implicit val cs: ContextShift[IO] = IO.contextShift(global) - implicit val timer: Temporal[IO] = IO.timer(global) + implicit val timer: Timer[IO] = IO.timer(global) // Transactor used by tests with rollback behavior and transactions def transactor: Transactor[IO] = DatabaseConfig.nonHikariTransactor[IO](dbName) diff --git a/project/Versions.scala b/project/Versions.scala index 57438f583..4be1cfdf0 100644 --- a/project/Versions.scala +++ b/project/Versions.scala @@ -7,7 +7,7 @@ object Versions { // which is the same as that in the GeoTrellis // https://github.com/locationtech/geotrellis/blob/v3.6.0/project/Dependencies.scala#L86 val AWSSdk2Version = "2.16.13" - val CatsEffectVersion = "3.3.14" + val CatsEffectVersion = "2.5.5" val CatsScalacheckVersion = "0.3.1" val CatsVersion = "2.8.0" val CirceFs2Version = "0.14.2" From d3e9a591a3ac1d886f819e0046d9c7ead4a7f995 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 17 Sep 2022 13:26:05 +0000 Subject: [PATCH 4/5] Applied Scalafix rule(s) github:typelevel/cats-effect/v3_0_0?sha=v3.0.0 --- .../scala/com/azavea/franklin/api/Server.scala | 3 ++- .../azavea/franklin/api/ServerOptions.scala | 2 +- .../api/services/CollectionItemsService.scala | 3 ++- .../api/services/CollectionsService.scala | 4 ++-- .../api/services/LandingPageService.scala | 3 ++- .../franklin/api/services/SearchService.scala | 3 ++- .../franklin/api/services/TileService.scala | 3 ++- .../azavea/franklin/commands/Commands.scala | 18 ++++++++---------- .../franklin/commands/DatabaseConfig.scala | 6 ++---- .../franklin/commands/DatabaseOptions.scala | 2 +- .../com/azavea/franklin/crawler/StacIO.scala | 4 ++-- .../franklin/crawler/StacItemImporter.scala | 2 +- .../com/azavea/franklin/database/Config.scala | 2 +- .../database/MosaicDefinitionDao.scala | 1 - .../extensions/validation/package.scala | 2 +- .../azavea/franklin/api/TestImplicits.scala | 2 +- .../com/azavea/franklin/api/TestServices.scala | 5 +++-- .../franklin/database/SetupTemplateDB.scala | 5 +++-- 18 files changed, 36 insertions(+), 34 deletions(-) diff --git a/application/src/main/scala/com/azavea/franklin/api/Server.scala b/application/src/main/scala/com/azavea/franklin/api/Server.scala index 8089371fb..d9dfca7e3 100644 --- a/application/src/main/scala/com/azavea/franklin/api/Server.scala +++ b/application/src/main/scala/com/azavea/franklin/api/Server.scala @@ -38,6 +38,7 @@ import scala.concurrent.ExecutionContext import java.util.concurrent.Executors import java.util.concurrent.TimeUnit +import cats.effect.Resource object Server extends IOApp.WithContext { @@ -153,7 +154,7 @@ $$$$ logger ).withLogging(true) ).orNotFound - serverBuilderBlocker <- Blocker[IO] + serverBuilderBlocker <- Resource.unit[IO] server <- { BlazeServerBuilder[IO](serverBuilderBlocker.blockingContext) .bindHttp(apiConfig.internalPort.value, "0.0.0.0") diff --git a/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala b/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala index db70ebbc7..9d9be3515 100644 --- a/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala +++ b/application/src/main/scala/com/azavea/franklin/api/ServerOptions.scala @@ -1,6 +1,6 @@ package com.azavea.franklin.api -import cats.effect.{ContextShift, Sync} +import cats.effect.Sync import io.circe.{CursorOp, DecodingFailure} import sttp.tapir.DecodeResult import sttp.tapir.server.http4s.Http4sServerOptions diff --git a/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala b/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala index ae84a52bb..a6ed90e72 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/CollectionItemsService.scala @@ -40,6 +40,7 @@ import sttp.tapir.server.http4s._ import java.net.URLDecoder import java.nio.charset.StandardCharsets +import cats.effect.Temporal class CollectionItemsService[F[_]: Concurrent]( xa: Transactor[F], @@ -48,7 +49,7 @@ class CollectionItemsService[F[_]: Concurrent]( rootLink: StacLink )( implicit contextShift: ContextShift[F], - timer: Timer[F], + timer: Temporal[F], serverOptions: Http4sServerOptions[F], backend: SttpBackend[F, Nothing, NothingT], logger: Logger[F] diff --git a/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala b/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala index f0539521c..1cf6512b8 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/CollectionsService.scala @@ -2,7 +2,6 @@ package com.azavea.franklin.api.services import cats.data.EitherT import cats.effect._ -import cats.effect.concurrent.Ref import cats.syntax.all._ import com.azavea.franklin.api.commands.ApiConfig import com.azavea.franklin.api.endpoints.CollectionEndpoints @@ -30,6 +29,7 @@ import sttp.tapir.server.http4s._ import java.net.URLDecoder import java.nio.charset.StandardCharsets import java.util.UUID +import cats.effect.Temporal class CollectionsService[F[_]: Concurrent]( xa: Transactor[F], @@ -37,7 +37,7 @@ class CollectionsService[F[_]: Concurrent]( collectionExtensionsRef: ExtensionRef[F, StacCollection] )( implicit contextShift: ContextShift[F], - timer: Timer[F], + timer: Temporal[F], serverOptions: Http4sServerOptions[F], backend: SttpBackend[F, Nothing, NothingT], logger: Logger[F] diff --git a/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala b/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala index 5d5010da9..195bd2f74 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/LandingPageService.scala @@ -20,10 +20,11 @@ import io.circe.syntax._ import org.http4s._ import org.http4s.dsl.Http4sDsl import sttp.tapir.server.http4s._ +import cats.effect.Temporal class LandingPageService[F[_]: Concurrent](apiConfig: ApiConfig)( implicit contextShift: ContextShift[F], - timer: Timer[F], + timer: Temporal[F], serverOptions: Http4sServerOptions[F] ) extends Http4sDsl[F] { diff --git a/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala b/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala index 0b30ec92e..375064b7c 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/SearchService.scala @@ -18,6 +18,7 @@ import io.circe.syntax._ import org.http4s._ import org.http4s.dsl.Http4sDsl import sttp.tapir.server.http4s._ +import cats.effect.Temporal class SearchService[F[_]: Concurrent]( apiConfig: ApiConfig, @@ -27,7 +28,7 @@ class SearchService[F[_]: Concurrent]( rootLink: StacLink )( implicit contextShift: ContextShift[F], - timerF: Timer[F], + timerF: Temporal[F], serverOptions: Http4sServerOptions[F] ) extends Http4sDsl[F] { diff --git a/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala b/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala index 7867b3d46..8d80970a2 100644 --- a/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala +++ b/application/src/main/scala/com/azavea/franklin/api/services/TileService.scala @@ -50,8 +50,9 @@ import scala.concurrent.duration._ import java.net.URLDecoder import java.nio.charset.StandardCharsets import java.util.UUID +import cats.effect.Temporal -class TileService[F[_]: Async: Concurrent: Parallel: Logger: Timer: ContextShift]( +class TileService[F[_]: Async: Concurrent: Parallel: Logger: Temporal: ContextShift]( serverHost: NonEmptyString, enableTiles: Boolean, path: Option[String], diff --git a/application/src/main/scala/com/azavea/franklin/commands/Commands.scala b/application/src/main/scala/com/azavea/franklin/commands/Commands.scala index 3552bf140..5d7dcdcf2 100644 --- a/application/src/main/scala/com/azavea/franklin/commands/Commands.scala +++ b/application/src/main/scala/com/azavea/franklin/commands/Commands.scala @@ -2,7 +2,7 @@ package com.azavea.franklin.api.commands import cats.data.NonEmptyList import cats.effect.Sync -import cats.effect.{ContextShift, ExitCode, IO} +import cats.effect.{ExitCode, IO} import cats.syntax.all._ import com.azavea.franklin.crawler.CatalogStacImport import com.azavea.franklin.crawler.StacItemImporter @@ -34,15 +34,13 @@ object Commands { ) private def runItemsImportOpts( - implicit sync: Sync[IO], - cs: ContextShift[IO] - ): Opts[RunItemsImport] = + implicit sync: Sync[IO]): Opts[RunItemsImport] = Opts.subcommand("import-items", "Import STAC items into an existing collection") { (Options.collectionID, Options.stacItems(sync), Options.databaseConfig, Options.dryRun) .mapN(RunItemsImport) } - private def runCatalogImportOpts(implicit cs: ContextShift[IO]): Opts[RunCatalogImport] = + private def runCatalogImportOpts: Opts[RunCatalogImport] = Opts.subcommand("import-catalog", "Import a STAC catalog") { ( Options.catalogRoot, @@ -51,12 +49,12 @@ object Commands { ).mapN(RunCatalogImport) } - private def runMigrationsOpts(implicit cs: ContextShift[IO]): Opts[RunMigrations] = + private def runMigrationsOpts: Opts[RunMigrations] = Opts.subcommand("migrate", "Runs migrations against database") { Options.databaseConfig map RunMigrations } - private def runServerOpts(implicit cs: ContextShift[IO]): Opts[RunServer] = + private def runServerOpts: Opts[RunServer] = Opts.subcommand("serve", "Runs web service") { (Options.apiConfig, Options.databaseConfig) mapN RunServer } @@ -78,7 +76,7 @@ object Commands { itemUris: NonEmptyList[String], config: DatabaseConfig, dryRun: Boolean - )(implicit cs: ContextShift[IO], backend: SttpBackend[IO, Nothing, NothingT]) = { + )(implicit backend: SttpBackend[IO, Nothing, NothingT]) = { val xa = config.getTransactor(dryRun) new StacItemImporter(collectionId, itemUris).runIO(xa) } @@ -88,14 +86,14 @@ object Commands { config: DatabaseConfig, dryRun: Boolean )( - implicit contextShift: ContextShift[IO], + implicit backend: SttpBackend[IO, Nothing, NothingT] ): IO[Unit] = { val xa = config.getTransactor(dryRun) new CatalogStacImport(stacCatalog).runIO(xa) } - def applicationCommand(implicit cs: ContextShift[IO]): Command[Product] = + def applicationCommand: Command[Product] = Command("", "Your Friendly Neighborhood OGC API - Features and STAC Web Service") { runServerOpts orElse runMigrationsOpts orElse runCatalogImportOpts orElse runItemsImportOpts } diff --git a/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala b/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala index faeebf3bf..3bc3091c7 100644 --- a/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala +++ b/application/src/main/scala/com/azavea/franklin/commands/DatabaseConfig.scala @@ -1,8 +1,6 @@ package com.azavea.franklin.api.commands import cats.effect.Async -import cats.effect.Blocker -import cats.effect.ContextShift import cats.effect.IO import cats.effect.Resource import com.zaxxer.hikari.HikariConfig @@ -36,7 +34,7 @@ case object DatabaseConfig { ) extends DatabaseConfig { val jdbcUrl = s"jdbc:postgresql://$dbHost:$dbPort/$dbName" - def getTransactor(dryRun: Boolean)(implicit contextShift: ContextShift[IO]) = { + def getTransactor(dryRun: Boolean) = { Transactor.strategy.set( Transactor.fromDriverManager[IO]( driver, @@ -64,7 +62,7 @@ case object DatabaseConfig { jdbcUrl: String ) extends DatabaseConfig { - def getTransactor(dryRun: Boolean)(implicit contextShift: ContextShift[IO]): Transactor[IO] = { + def getTransactor(dryRun: Boolean): Transactor[IO] = { val blockingEc = ExecutionContext.fromExecutor( Executors.newCachedThreadPool( new ThreadFactory { diff --git a/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala b/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala index 2840d7de3..a3457b6f3 100644 --- a/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala +++ b/application/src/main/scala/com/azavea/franklin/commands/DatabaseOptions.scala @@ -53,7 +53,7 @@ trait DatabaseOptions { help = databaseConnectionStringHelp ) orElse Opts.env[String]("DB_CONNECTION_STRING", help = databaseConnectionStringHelp) - def databaseConfig(implicit contextShift: ContextShift[IO]): Opts[DatabaseConfig] = + def databaseConfig: Opts[DatabaseConfig] = ((connectionString map { DatabaseConfig.FromConnectionString }) orElse ( databaseUser, databasePassword, diff --git a/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala b/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala index a6ec1c91a..0613d28a4 100644 --- a/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala +++ b/application/src/main/scala/com/azavea/franklin/crawler/StacIO.scala @@ -1,7 +1,7 @@ package com.azavea.franklin.crawler import cats.data.{NonEmptyList, Validated, ValidatedNel} -import cats.effect.{ContextShift, IO} +import cats.effect.IO import cats.syntax.all._ import com.amazonaws.services.s3.AmazonS3ClientBuilder import com.azavea.stac4s.{`application/json`, StacCollection, StacItem, StacLink, StacLinkType} @@ -148,7 +148,7 @@ object StacIO { rewriteSourceIfPresent: Boolean, inCollectionId: Option[String] )( - implicit contextShift: ContextShift[IO], + implicit logger: Logger[IO], backend: SttpBackend[IO, Nothing, NothingT] ): IO[StacItem] = { diff --git a/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala b/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala index 5dec3bc59..f1d8d28b0 100644 --- a/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala +++ b/application/src/main/scala/com/azavea/franklin/crawler/StacItemImporter.scala @@ -2,7 +2,7 @@ package com.azavea.franklin.crawler import cats.data.EitherT import cats.data.NonEmptyList -import cats.effect.{ContextShift, IO} +import cats.effect.IO import cats.syntax.all._ import com.azavea.franklin.database.{getItemsBulkExtent, StacCollectionDao, StacItemDao} import com.azavea.stac4s._ diff --git a/application/src/main/scala/com/azavea/franklin/database/Config.scala b/application/src/main/scala/com/azavea/franklin/database/Config.scala index 0fac8aa63..58d007c0d 100644 --- a/application/src/main/scala/com/azavea/franklin/database/Config.scala +++ b/application/src/main/scala/com/azavea/franklin/database/Config.scala @@ -29,7 +29,7 @@ object DatabaseConfig { val dbMaximumPoolSize: Int = Properties.envOrElse("POSTGRES_DB_POOL_SIZE", "5").toInt - def nonHikariTransactor[F[_]: Async](databaseName: String)(implicit cs: ContextShift[F]) = { + def nonHikariTransactor[F[_]: Async](databaseName: String) = { Transactor.fromDriverManager[F]( "org.postgresql.Driver", jdbcNoDBUrl + databaseName, diff --git a/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala b/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala index f524539ff..9ea2febbf 100644 --- a/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala +++ b/application/src/main/scala/com/azavea/franklin/database/MosaicDefinitionDao.scala @@ -2,7 +2,6 @@ package com.azavea.franklin.database import cats.data.NonEmptyList import cats.data.OptionT -import cats.effect.ContextShift import cats.effect.IO import cats.effect.LiftIO import cats.syntax.applicative._ diff --git a/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala b/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala index 834fd9584..9d577483b 100644 --- a/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala +++ b/application/src/main/scala/com/azavea/franklin/extensions/validation/package.scala @@ -3,7 +3,6 @@ package com.azavea.franklin.extensions import cats.Functor import cats.data.NonEmptyList import cats.effect.Sync -import cats.effect.concurrent.Ref import cats.syntax.all._ import com.azavea.franklin.extensions.validation.syntax._ import com.azavea.stac4s.StacCollection @@ -28,6 +27,7 @@ import sttp.client.circe._ import sttp.model.{Uri => SttpUri} import scala.util.{Failure, Success, Try} +import cats.effect.Ref package object validation { diff --git a/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala b/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala index ab1bded6f..5a28a969c 100644 --- a/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala +++ b/application/src/test/scala/com/azavea/franklin/api/TestImplicits.scala @@ -1,7 +1,7 @@ package com.azavea.franklin.api import cats.Applicative -import cats.effect.{Concurrent, ContextShift, Timer} +import cats.effect.Concurrent import cats.syntax.functor._ import com.azavea.franklin.api.commands.ApiConfig import com.azavea.franklin.api.services.{CollectionItemsService, CollectionsService, SearchService} diff --git a/application/src/test/scala/com/azavea/franklin/api/TestServices.scala b/application/src/test/scala/com/azavea/franklin/api/TestServices.scala index 8d98e0207..4be04d56f 100644 --- a/application/src/test/scala/com/azavea/franklin/api/TestServices.scala +++ b/application/src/test/scala/com/azavea/franklin/api/TestServices.scala @@ -1,7 +1,7 @@ package com.azavea.franklin.api import cats.Applicative -import cats.effect.{Concurrent, ContextShift, Timer} +import cats.effect.Concurrent import cats.syntax.functor._ import com.azavea.franklin.api.commands.ApiConfig import com.azavea.franklin.api.services.{CollectionItemsService, CollectionsService, SearchService} @@ -11,10 +11,11 @@ import doobie.Transactor import eu.timepit.refined.types.numeric.{NonNegInt, PosInt} import io.chrisdavenport.log4cats.noop.NoOpLogger import sttp.client.asynchttpclient.cats.AsyncHttpClientCatsBackend +import cats.effect.Temporal class TestServices[F[_]: Concurrent](xa: Transactor[F])( implicit cs: ContextShift[F], - timer: Timer[F] + timer: Temporal[F] ) extends TestImplicits[F] { val rootLink = StacLink( diff --git a/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala b/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala index fc5dc6dce..9de824b06 100644 --- a/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala +++ b/application/src/test/scala/com/azavea/franklin/database/SetupTemplateDB.scala @@ -1,6 +1,6 @@ package com.azavea.franklin.database -import cats.effect.{ContextShift, IO, Timer} +import cats.effect.IO import cats.syntax.all._ import doobie._ import doobie.free.connection.unit @@ -11,6 +11,7 @@ import org.specs2._ import org.specs2.specification.{AfterAll, BeforeAll} import scala.concurrent.ExecutionContext.Implicits.global +import cats.effect.Temporal object SetupTemplateDB { val templateDbName: String = "testing_template" @@ -56,7 +57,7 @@ trait TestDatabaseSpec extends Specification with BeforeAll with AfterAll { implicit val cs: ContextShift[IO] = IO.contextShift(global) - implicit val timer: Timer[IO] = IO.timer(global) + implicit val timer: Temporal[IO] = IO.timer(global) // Transactor used by tests with rollback behavior and transactions def transactor: Transactor[IO] = DatabaseConfig.nonHikariTransactor[IO](dbName) From ac66338bd5cc1adfe21eed7ef8f3ca35ec4c2f7a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 17 Sep 2022 13:28:20 +0000 Subject: [PATCH 5/5] Update cats-effect to 3.3.14 --- project/Versions.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Versions.scala b/project/Versions.scala index 19e0dd2db..c86d69473 100644 --- a/project/Versions.scala +++ b/project/Versions.scala @@ -7,7 +7,7 @@ object Versions { // which is the same as that in the GeoTrellis // https://github.com/locationtech/geotrellis/blob/v3.6.0/project/Dependencies.scala#L86 val AWSSdk2Version = "2.16.13" - val CatsEffectVersion = "2.5.5" + val CatsEffectVersion = "3.3.14" val CatsScalacheckVersion = "0.3.2" val CatsVersion = "2.8.0" val CirceFs2Version = "0.14.2"