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

Update cats-effect to 3.3.13 #1239

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -30,14 +29,15 @@ 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],
apiConfig: ApiConfig,
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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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] {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
Expand All @@ -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)
}
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -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}
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion project/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.13"
val CatsScalacheckVersion = "0.3.1"
val CatsVersion = "2.7.0"
val CirceFs2Version = "0.14.2"
Expand Down