From fbcf2a84204b552b11dfa74ede59b7ab33ee65ab Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 29 Jun 2023 11:33:17 +0000 Subject: [PATCH 1/5] Applied Scalafix rule(s) github:typelevel/cats-effect/v3_0_0?sha=v3.0.0 --- api/src/test/scala/slog4s/EffectTest.scala | 5 +++-- api/src/test/scala/slog4s/MockClock.scala | 2 +- .../slog4s/console/internal/LoggingRuntimeImpl.scala | 2 +- .../slog4s/console/internal/SyncFormatter.scala | 2 +- .../scala/slog4s/console/ConsoleConfigTest.scala | 9 +++++---- .../scala/slog4s/console/ConsoleLoggerTest.scala | 10 +++++----- .../src/test/scala/slog4s/shared/ContextTest.scala | 12 ++++++------ 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/api/src/test/scala/slog4s/EffectTest.scala b/api/src/test/scala/slog4s/EffectTest.scala index 991933a..a758782 100644 --- a/api/src/test/scala/slog4s/EffectTest.scala +++ b/api/src/test/scala/slog4s/EffectTest.scala @@ -1,17 +1,18 @@ package slog4s import cats.effect.syntax.all._ -import cats.effect.{ConcurrentEffect, Sync, Timer} +import cats.effect.{ConcurrentEffect, Sync} import cats.syntax.flatMap._ import org.scalactic.source import org.scalatest.funspec.FixtureAnyFunSpec import scala.concurrent.duration._ +import cats.effect.Temporal abstract class EffectTest[F[_]] extends FixtureAnyFunSpec { protected def asEffect(fixtureParam: FixtureParam): ConcurrentEffect[F] - protected def asTimer(fixtureParam: FixtureParam): Timer[F] + protected def asTimer(fixtureParam: FixtureParam): Temporal[F] protected def timeout: FiniteDuration = 10.seconds def it_( diff --git a/api/src/test/scala/slog4s/MockClock.scala b/api/src/test/scala/slog4s/MockClock.scala index 4c84be4..0ed7b6b 100644 --- a/api/src/test/scala/slog4s/MockClock.scala +++ b/api/src/test/scala/slog4s/MockClock.scala @@ -3,12 +3,12 @@ package slog4s import java.util.concurrent.TimeUnit import cats.Monad -import cats.effect.concurrent.Ref import cats.effect.{Clock, Sync} import cats.syntax.flatMap._ import cats.syntax.functor._ import scala.concurrent.duration.Duration +import cats.effect.Ref class MockClock[F[_]](val real: Ref[F, Long], val mono: Ref[F, Long])(implicit F: Monad[F] diff --git a/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala b/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala index d313423..956d2d6 100644 --- a/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala +++ b/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala @@ -1,11 +1,11 @@ package slog4s.console.internal -import cats.effect.concurrent.Semaphore import cats.effect.{Clock, Concurrent, Sync} import cats.syntax.functor._ import slog4s.console.ConsoleConfig import slog4s.shared.{AsContext, LoggingRuntime} import slog4s.{Logger, LoggerFactory, LoggingContext, StructureBuilder} +import cats.effect.std.Semaphore private[console] class LoggingRuntimeImpl[F[ _ diff --git a/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala b/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala index 83d7893..e8beb09 100644 --- a/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala +++ b/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala @@ -2,8 +2,8 @@ package slog4s.console.internal import java.time.Instant -import cats.effect.concurrent.Semaphore import slog4s.{Level, Location} +import cats.effect.std.Semaphore private[console] class SyncFormatter[F[_], T]( semaphore: Semaphore[F], diff --git a/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala b/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala index d2d7a12..c2ee83b 100644 --- a/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala +++ b/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala @@ -1,6 +1,6 @@ package slog4s.console -import cats.effect.{ConcurrentEffect, ContextShift, IO, Timer} +import cats.effect.{ConcurrentEffect, IO} import cats.syntax.functor._ import cats.syntax.flatMap._ import org.scalactic.source.Position @@ -9,19 +9,20 @@ import slog4s.{EffectTest, Level} import slog4s.console.ConsoleConfigTest.Fixture import scala.concurrent.ExecutionContext +import cats.effect.Temporal class ConsoleConfigTest extends EffectTest[IO] { override protected def asEffect( fixtureParam: FixtureParam ): ConcurrentEffect[IO] = fixtureParam.F - override protected def asTimer(fixtureParam: FixtureParam): Timer[IO] = + override protected def asTimer(fixtureParam: FixtureParam): Temporal[IO] = fixtureParam.timer override protected def withFixture(test: OneArgTest): Outcome = { implicit val contextShift: ContextShift[IO] = IO.contextShift(ExecutionContext.global) - implicit val timer: Timer[IO] = IO.timer(ExecutionContext.global) + implicit val timer: Temporal[IO] = IO.timer(ExecutionContext.global) test(new Fixture[IO]()) } @@ -57,7 +58,7 @@ object ConsoleConfigTest { import org.scalatest.matchers.should.Matchers._ class Fixture[F[_]](implicit val F: ConcurrentEffect[F], - val timer: Timer[F] + val timer: Temporal[F] ) { def validateLevel( fLevel: F[Level] diff --git a/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala b/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala index 74c107d..e55cfdd 100644 --- a/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala +++ b/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala @@ -2,8 +2,7 @@ package slog4s.console import java.io.{ByteArrayOutputStream, PrintStream} import java.util.concurrent.{Executors, ThreadFactory} -import cats.effect.concurrent.Ref -import cats.effect.{ConcurrentEffect, ContextShift, IO, Resource, Sync, Timer} +import cats.effect.{ConcurrentEffect, IO, Resource, Sync} import cats.syntax.all._ import slog4s.Location.Code import slog4s.console.ConsoleLoggerTest.{Fixture, Output} @@ -16,13 +15,14 @@ import slog4s.shared.{ import slog4s._ import scala.concurrent.ExecutionContext +import cats.effect.{ Ref, Temporal } abstract class ConsoleLoggerTest[F[_]](format: Format) extends EffectTest[F] { override protected def asEffect( fixtureParam: FixtureParam ): ConcurrentEffect[F] = fixtureParam.F - override protected def asTimer(fixtureParam: FixtureParam): Timer[F] = + override protected def asTimer(fixtureParam: FixtureParam): Temporal[F] = fixtureParam.T override type FixtureParam = ConsoleLoggerTest.Fixture[F] @@ -46,7 +46,7 @@ abstract class ConsoleLoggerTest[F[_]](format: Format) extends EffectTest[F] { implicit val contextShift: ContextShift[IO] = IO.contextShift(ec) implicit val F: Sync[IO] = ConcurrentEffect[IO] implicit val mockClock: MockClock[IO] = MockClock.make[IO].unsafeRunSync() - implicit val timer: Timer[IO] = IO.timer(ec) + implicit val timer: Temporal[IO] = IO.timer(ec) val contextRuntimeBuilder = new ContextRuntimeBuilder[IO] { override def make[T](empty: T): IO[ContextRuntime[IO, T]] = { Ref.of(empty).map { context => @@ -101,7 +101,7 @@ object ConsoleLoggerTest { )(implicit val F: ConcurrentEffect[F], val C: MockClock[F], - val T: Timer[F] + val T: Temporal[F] ) { val loggerName = "test-logger" val logger = loggerFactory.make(loggerName) diff --git a/shared/src/test/scala/slog4s/shared/ContextTest.scala b/shared/src/test/scala/slog4s/shared/ContextTest.scala index 405dc31..3c19388 100644 --- a/shared/src/test/scala/slog4s/shared/ContextTest.scala +++ b/shared/src/test/scala/slog4s/shared/ContextTest.scala @@ -1,19 +1,19 @@ package slog4s.shared -import cats.effect.concurrent.Deferred import cats.effect.syntax.all._ -import cats.effect.{Bracket, ConcurrentEffect, Timer} +import cats.effect.ConcurrentEffect import cats.syntax.flatMap._ import cats.syntax.functor._ import slog4s.EffectTest import slog4s.shared.ContextTest.Fixture +import cats.effect.{ Deferred, MonadCancel, Temporal } abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { override type FixtureParam = Fixture[F] override protected def asEffect( fixtureParam: Fixture[F] ): ConcurrentEffect[F] = fixtureParam.F - override protected def asTimer(fixtureParam: Fixture[F]): Timer[F] = + override protected def asTimer(fixtureParam: Fixture[F]): Temporal[F] = fixtureParam.T describe(s"$runtimeName-based context") { @@ -95,8 +95,8 @@ abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { promise <- Deferred[F, Unit] // promise used to indicate that a fiber has entered inside `guarantee`. fiberStarted <- Deferred[F, Unit] - fiber <- Bracket[F, Throwable] - .guarantee(fiberCode(fiberStarted))(promise.complete(())) + fiber <- MonadCancel[F, Throwable] + .guarantee(fiberCode(fiberStarted), promise.complete(())) .start _ <- fiberStarted.get _ <- fiber.cancel.start @@ -110,7 +110,7 @@ abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { object ContextTest { final class Fixture[F[_]](implicit val F: ConcurrentEffect[F], - val T: Timer[F], + val T: Temporal[F], val asContext: AsContext[F, Int], val useContext: UseContext[F, Int] ) From 6005b0c89438547925198140011dd716cd82e6a6 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 29 Jun 2023 11:36:30 +0000 Subject: [PATCH 2/5] Update cats-effect to 3.5.1 --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index ef86093..cb09b6a 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -2,7 +2,7 @@ import sbt._ object Dependencies { lazy val catsCore = "org.typelevel" %% "cats-core" % "2.9.0" - lazy val catsEffect = "org.typelevel" %% "cats-effect" % "2.5.5" + lazy val catsEffect = "org.typelevel" %% "cats-effect" % "3.5.1" lazy val catsMtl = "org.typelevel" %% "cats-mtl-core" % "0.7.1" lazy val circeCore = "io.circe" %% "circe-core" % "0.14.5" lazy val circeLiteral = From bc4904afed8fb908885ec46f9f1e49c6b08b190a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 22 Sep 2023 13:18:46 +0000 Subject: [PATCH 3/5] Revert commit(s) 6005b0c, fbcf2a8 --- api/src/test/scala/slog4s/EffectTest.scala | 5 ++--- api/src/test/scala/slog4s/MockClock.scala | 2 +- .../slog4s/console/internal/LoggingRuntimeImpl.scala | 2 +- .../slog4s/console/internal/SyncFormatter.scala | 2 +- .../scala/slog4s/console/ConsoleConfigTest.scala | 9 ++++----- .../scala/slog4s/console/ConsoleLoggerTest.scala | 10 +++++----- project/Dependencies.scala | 2 +- .../src/test/scala/slog4s/shared/ContextTest.scala | 12 ++++++------ 8 files changed, 21 insertions(+), 23 deletions(-) diff --git a/api/src/test/scala/slog4s/EffectTest.scala b/api/src/test/scala/slog4s/EffectTest.scala index a758782..991933a 100644 --- a/api/src/test/scala/slog4s/EffectTest.scala +++ b/api/src/test/scala/slog4s/EffectTest.scala @@ -1,18 +1,17 @@ package slog4s import cats.effect.syntax.all._ -import cats.effect.{ConcurrentEffect, Sync} +import cats.effect.{ConcurrentEffect, Sync, Timer} import cats.syntax.flatMap._ import org.scalactic.source import org.scalatest.funspec.FixtureAnyFunSpec import scala.concurrent.duration._ -import cats.effect.Temporal abstract class EffectTest[F[_]] extends FixtureAnyFunSpec { protected def asEffect(fixtureParam: FixtureParam): ConcurrentEffect[F] - protected def asTimer(fixtureParam: FixtureParam): Temporal[F] + protected def asTimer(fixtureParam: FixtureParam): Timer[F] protected def timeout: FiniteDuration = 10.seconds def it_( diff --git a/api/src/test/scala/slog4s/MockClock.scala b/api/src/test/scala/slog4s/MockClock.scala index 0ed7b6b..4c84be4 100644 --- a/api/src/test/scala/slog4s/MockClock.scala +++ b/api/src/test/scala/slog4s/MockClock.scala @@ -3,12 +3,12 @@ package slog4s import java.util.concurrent.TimeUnit import cats.Monad +import cats.effect.concurrent.Ref import cats.effect.{Clock, Sync} import cats.syntax.flatMap._ import cats.syntax.functor._ import scala.concurrent.duration.Duration -import cats.effect.Ref class MockClock[F[_]](val real: Ref[F, Long], val mono: Ref[F, Long])(implicit F: Monad[F] diff --git a/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala b/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala index 956d2d6..d313423 100644 --- a/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala +++ b/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala @@ -1,11 +1,11 @@ package slog4s.console.internal +import cats.effect.concurrent.Semaphore import cats.effect.{Clock, Concurrent, Sync} import cats.syntax.functor._ import slog4s.console.ConsoleConfig import slog4s.shared.{AsContext, LoggingRuntime} import slog4s.{Logger, LoggerFactory, LoggingContext, StructureBuilder} -import cats.effect.std.Semaphore private[console] class LoggingRuntimeImpl[F[ _ diff --git a/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala b/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala index e8beb09..83d7893 100644 --- a/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala +++ b/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala @@ -2,8 +2,8 @@ package slog4s.console.internal import java.time.Instant +import cats.effect.concurrent.Semaphore import slog4s.{Level, Location} -import cats.effect.std.Semaphore private[console] class SyncFormatter[F[_], T]( semaphore: Semaphore[F], diff --git a/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala b/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala index c2ee83b..d2d7a12 100644 --- a/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala +++ b/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala @@ -1,6 +1,6 @@ package slog4s.console -import cats.effect.{ConcurrentEffect, IO} +import cats.effect.{ConcurrentEffect, ContextShift, IO, Timer} import cats.syntax.functor._ import cats.syntax.flatMap._ import org.scalactic.source.Position @@ -9,20 +9,19 @@ import slog4s.{EffectTest, Level} import slog4s.console.ConsoleConfigTest.Fixture import scala.concurrent.ExecutionContext -import cats.effect.Temporal class ConsoleConfigTest extends EffectTest[IO] { override protected def asEffect( fixtureParam: FixtureParam ): ConcurrentEffect[IO] = fixtureParam.F - override protected def asTimer(fixtureParam: FixtureParam): Temporal[IO] = + override protected def asTimer(fixtureParam: FixtureParam): Timer[IO] = fixtureParam.timer override protected def withFixture(test: OneArgTest): Outcome = { implicit val contextShift: ContextShift[IO] = IO.contextShift(ExecutionContext.global) - implicit val timer: Temporal[IO] = IO.timer(ExecutionContext.global) + implicit val timer: Timer[IO] = IO.timer(ExecutionContext.global) test(new Fixture[IO]()) } @@ -58,7 +57,7 @@ object ConsoleConfigTest { import org.scalatest.matchers.should.Matchers._ class Fixture[F[_]](implicit val F: ConcurrentEffect[F], - val timer: Temporal[F] + val timer: Timer[F] ) { def validateLevel( fLevel: F[Level] diff --git a/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala b/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala index e55cfdd..74c107d 100644 --- a/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala +++ b/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala @@ -2,7 +2,8 @@ package slog4s.console import java.io.{ByteArrayOutputStream, PrintStream} import java.util.concurrent.{Executors, ThreadFactory} -import cats.effect.{ConcurrentEffect, IO, Resource, Sync} +import cats.effect.concurrent.Ref +import cats.effect.{ConcurrentEffect, ContextShift, IO, Resource, Sync, Timer} import cats.syntax.all._ import slog4s.Location.Code import slog4s.console.ConsoleLoggerTest.{Fixture, Output} @@ -15,14 +16,13 @@ import slog4s.shared.{ import slog4s._ import scala.concurrent.ExecutionContext -import cats.effect.{ Ref, Temporal } abstract class ConsoleLoggerTest[F[_]](format: Format) extends EffectTest[F] { override protected def asEffect( fixtureParam: FixtureParam ): ConcurrentEffect[F] = fixtureParam.F - override protected def asTimer(fixtureParam: FixtureParam): Temporal[F] = + override protected def asTimer(fixtureParam: FixtureParam): Timer[F] = fixtureParam.T override type FixtureParam = ConsoleLoggerTest.Fixture[F] @@ -46,7 +46,7 @@ abstract class ConsoleLoggerTest[F[_]](format: Format) extends EffectTest[F] { implicit val contextShift: ContextShift[IO] = IO.contextShift(ec) implicit val F: Sync[IO] = ConcurrentEffect[IO] implicit val mockClock: MockClock[IO] = MockClock.make[IO].unsafeRunSync() - implicit val timer: Temporal[IO] = IO.timer(ec) + implicit val timer: Timer[IO] = IO.timer(ec) val contextRuntimeBuilder = new ContextRuntimeBuilder[IO] { override def make[T](empty: T): IO[ContextRuntime[IO, T]] = { Ref.of(empty).map { context => @@ -101,7 +101,7 @@ object ConsoleLoggerTest { )(implicit val F: ConcurrentEffect[F], val C: MockClock[F], - val T: Temporal[F] + val T: Timer[F] ) { val loggerName = "test-logger" val logger = loggerFactory.make(loggerName) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index cb09b6a..ef86093 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -2,7 +2,7 @@ import sbt._ object Dependencies { lazy val catsCore = "org.typelevel" %% "cats-core" % "2.9.0" - lazy val catsEffect = "org.typelevel" %% "cats-effect" % "3.5.1" + lazy val catsEffect = "org.typelevel" %% "cats-effect" % "2.5.5" lazy val catsMtl = "org.typelevel" %% "cats-mtl-core" % "0.7.1" lazy val circeCore = "io.circe" %% "circe-core" % "0.14.5" lazy val circeLiteral = diff --git a/shared/src/test/scala/slog4s/shared/ContextTest.scala b/shared/src/test/scala/slog4s/shared/ContextTest.scala index 3c19388..405dc31 100644 --- a/shared/src/test/scala/slog4s/shared/ContextTest.scala +++ b/shared/src/test/scala/slog4s/shared/ContextTest.scala @@ -1,19 +1,19 @@ package slog4s.shared +import cats.effect.concurrent.Deferred import cats.effect.syntax.all._ -import cats.effect.ConcurrentEffect +import cats.effect.{Bracket, ConcurrentEffect, Timer} import cats.syntax.flatMap._ import cats.syntax.functor._ import slog4s.EffectTest import slog4s.shared.ContextTest.Fixture -import cats.effect.{ Deferred, MonadCancel, Temporal } abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { override type FixtureParam = Fixture[F] override protected def asEffect( fixtureParam: Fixture[F] ): ConcurrentEffect[F] = fixtureParam.F - override protected def asTimer(fixtureParam: Fixture[F]): Temporal[F] = + override protected def asTimer(fixtureParam: Fixture[F]): Timer[F] = fixtureParam.T describe(s"$runtimeName-based context") { @@ -95,8 +95,8 @@ abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { promise <- Deferred[F, Unit] // promise used to indicate that a fiber has entered inside `guarantee`. fiberStarted <- Deferred[F, Unit] - fiber <- MonadCancel[F, Throwable] - .guarantee(fiberCode(fiberStarted), promise.complete(())) + fiber <- Bracket[F, Throwable] + .guarantee(fiberCode(fiberStarted))(promise.complete(())) .start _ <- fiberStarted.get _ <- fiber.cancel.start @@ -110,7 +110,7 @@ abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { object ContextTest { final class Fixture[F[_]](implicit val F: ConcurrentEffect[F], - val T: Temporal[F], + val T: Timer[F], val asContext: AsContext[F, Int], val useContext: UseContext[F, Int] ) From 371768202a1fd2f5071d77d27371387ccc9fea8a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 22 Sep 2023 13:23:26 +0000 Subject: [PATCH 4/5] Applied Scalafix rule(s) github:typelevel/cats-effect/v3_0_0?sha=v3.0.0 --- api/src/test/scala/slog4s/EffectTest.scala | 5 +++-- api/src/test/scala/slog4s/MockClock.scala | 2 +- .../slog4s/console/internal/LoggingRuntimeImpl.scala | 2 +- .../slog4s/console/internal/SyncFormatter.scala | 2 +- .../scala/slog4s/console/ConsoleConfigTest.scala | 9 +++++---- .../scala/slog4s/console/ConsoleLoggerTest.scala | 10 +++++----- .../src/test/scala/slog4s/shared/ContextTest.scala | 12 ++++++------ 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/api/src/test/scala/slog4s/EffectTest.scala b/api/src/test/scala/slog4s/EffectTest.scala index 991933a..a758782 100644 --- a/api/src/test/scala/slog4s/EffectTest.scala +++ b/api/src/test/scala/slog4s/EffectTest.scala @@ -1,17 +1,18 @@ package slog4s import cats.effect.syntax.all._ -import cats.effect.{ConcurrentEffect, Sync, Timer} +import cats.effect.{ConcurrentEffect, Sync} import cats.syntax.flatMap._ import org.scalactic.source import org.scalatest.funspec.FixtureAnyFunSpec import scala.concurrent.duration._ +import cats.effect.Temporal abstract class EffectTest[F[_]] extends FixtureAnyFunSpec { protected def asEffect(fixtureParam: FixtureParam): ConcurrentEffect[F] - protected def asTimer(fixtureParam: FixtureParam): Timer[F] + protected def asTimer(fixtureParam: FixtureParam): Temporal[F] protected def timeout: FiniteDuration = 10.seconds def it_( diff --git a/api/src/test/scala/slog4s/MockClock.scala b/api/src/test/scala/slog4s/MockClock.scala index 4c84be4..0ed7b6b 100644 --- a/api/src/test/scala/slog4s/MockClock.scala +++ b/api/src/test/scala/slog4s/MockClock.scala @@ -3,12 +3,12 @@ package slog4s import java.util.concurrent.TimeUnit import cats.Monad -import cats.effect.concurrent.Ref import cats.effect.{Clock, Sync} import cats.syntax.flatMap._ import cats.syntax.functor._ import scala.concurrent.duration.Duration +import cats.effect.Ref class MockClock[F[_]](val real: Ref[F, Long], val mono: Ref[F, Long])(implicit F: Monad[F] diff --git a/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala b/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala index d313423..956d2d6 100644 --- a/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala +++ b/console/src/main/scala/slog4s/console/internal/LoggingRuntimeImpl.scala @@ -1,11 +1,11 @@ package slog4s.console.internal -import cats.effect.concurrent.Semaphore import cats.effect.{Clock, Concurrent, Sync} import cats.syntax.functor._ import slog4s.console.ConsoleConfig import slog4s.shared.{AsContext, LoggingRuntime} import slog4s.{Logger, LoggerFactory, LoggingContext, StructureBuilder} +import cats.effect.std.Semaphore private[console] class LoggingRuntimeImpl[F[ _ diff --git a/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala b/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala index 83d7893..e8beb09 100644 --- a/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala +++ b/console/src/main/scala/slog4s/console/internal/SyncFormatter.scala @@ -2,8 +2,8 @@ package slog4s.console.internal import java.time.Instant -import cats.effect.concurrent.Semaphore import slog4s.{Level, Location} +import cats.effect.std.Semaphore private[console] class SyncFormatter[F[_], T]( semaphore: Semaphore[F], diff --git a/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala b/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala index d2d7a12..c2ee83b 100644 --- a/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala +++ b/console/src/test/scala/slog4s/console/ConsoleConfigTest.scala @@ -1,6 +1,6 @@ package slog4s.console -import cats.effect.{ConcurrentEffect, ContextShift, IO, Timer} +import cats.effect.{ConcurrentEffect, IO} import cats.syntax.functor._ import cats.syntax.flatMap._ import org.scalactic.source.Position @@ -9,19 +9,20 @@ import slog4s.{EffectTest, Level} import slog4s.console.ConsoleConfigTest.Fixture import scala.concurrent.ExecutionContext +import cats.effect.Temporal class ConsoleConfigTest extends EffectTest[IO] { override protected def asEffect( fixtureParam: FixtureParam ): ConcurrentEffect[IO] = fixtureParam.F - override protected def asTimer(fixtureParam: FixtureParam): Timer[IO] = + override protected def asTimer(fixtureParam: FixtureParam): Temporal[IO] = fixtureParam.timer override protected def withFixture(test: OneArgTest): Outcome = { implicit val contextShift: ContextShift[IO] = IO.contextShift(ExecutionContext.global) - implicit val timer: Timer[IO] = IO.timer(ExecutionContext.global) + implicit val timer: Temporal[IO] = IO.timer(ExecutionContext.global) test(new Fixture[IO]()) } @@ -57,7 +58,7 @@ object ConsoleConfigTest { import org.scalatest.matchers.should.Matchers._ class Fixture[F[_]](implicit val F: ConcurrentEffect[F], - val timer: Timer[F] + val timer: Temporal[F] ) { def validateLevel( fLevel: F[Level] diff --git a/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala b/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala index 74c107d..e55cfdd 100644 --- a/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala +++ b/console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala @@ -2,8 +2,7 @@ package slog4s.console import java.io.{ByteArrayOutputStream, PrintStream} import java.util.concurrent.{Executors, ThreadFactory} -import cats.effect.concurrent.Ref -import cats.effect.{ConcurrentEffect, ContextShift, IO, Resource, Sync, Timer} +import cats.effect.{ConcurrentEffect, IO, Resource, Sync} import cats.syntax.all._ import slog4s.Location.Code import slog4s.console.ConsoleLoggerTest.{Fixture, Output} @@ -16,13 +15,14 @@ import slog4s.shared.{ import slog4s._ import scala.concurrent.ExecutionContext +import cats.effect.{ Ref, Temporal } abstract class ConsoleLoggerTest[F[_]](format: Format) extends EffectTest[F] { override protected def asEffect( fixtureParam: FixtureParam ): ConcurrentEffect[F] = fixtureParam.F - override protected def asTimer(fixtureParam: FixtureParam): Timer[F] = + override protected def asTimer(fixtureParam: FixtureParam): Temporal[F] = fixtureParam.T override type FixtureParam = ConsoleLoggerTest.Fixture[F] @@ -46,7 +46,7 @@ abstract class ConsoleLoggerTest[F[_]](format: Format) extends EffectTest[F] { implicit val contextShift: ContextShift[IO] = IO.contextShift(ec) implicit val F: Sync[IO] = ConcurrentEffect[IO] implicit val mockClock: MockClock[IO] = MockClock.make[IO].unsafeRunSync() - implicit val timer: Timer[IO] = IO.timer(ec) + implicit val timer: Temporal[IO] = IO.timer(ec) val contextRuntimeBuilder = new ContextRuntimeBuilder[IO] { override def make[T](empty: T): IO[ContextRuntime[IO, T]] = { Ref.of(empty).map { context => @@ -101,7 +101,7 @@ object ConsoleLoggerTest { )(implicit val F: ConcurrentEffect[F], val C: MockClock[F], - val T: Timer[F] + val T: Temporal[F] ) { val loggerName = "test-logger" val logger = loggerFactory.make(loggerName) diff --git a/shared/src/test/scala/slog4s/shared/ContextTest.scala b/shared/src/test/scala/slog4s/shared/ContextTest.scala index 405dc31..3c19388 100644 --- a/shared/src/test/scala/slog4s/shared/ContextTest.scala +++ b/shared/src/test/scala/slog4s/shared/ContextTest.scala @@ -1,19 +1,19 @@ package slog4s.shared -import cats.effect.concurrent.Deferred import cats.effect.syntax.all._ -import cats.effect.{Bracket, ConcurrentEffect, Timer} +import cats.effect.ConcurrentEffect import cats.syntax.flatMap._ import cats.syntax.functor._ import slog4s.EffectTest import slog4s.shared.ContextTest.Fixture +import cats.effect.{ Deferred, MonadCancel, Temporal } abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { override type FixtureParam = Fixture[F] override protected def asEffect( fixtureParam: Fixture[F] ): ConcurrentEffect[F] = fixtureParam.F - override protected def asTimer(fixtureParam: Fixture[F]): Timer[F] = + override protected def asTimer(fixtureParam: Fixture[F]): Temporal[F] = fixtureParam.T describe(s"$runtimeName-based context") { @@ -95,8 +95,8 @@ abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { promise <- Deferred[F, Unit] // promise used to indicate that a fiber has entered inside `guarantee`. fiberStarted <- Deferred[F, Unit] - fiber <- Bracket[F, Throwable] - .guarantee(fiberCode(fiberStarted))(promise.complete(())) + fiber <- MonadCancel[F, Throwable] + .guarantee(fiberCode(fiberStarted), promise.complete(())) .start _ <- fiberStarted.get _ <- fiber.cancel.start @@ -110,7 +110,7 @@ abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] { object ContextTest { final class Fixture[F[_]](implicit val F: ConcurrentEffect[F], - val T: Timer[F], + val T: Temporal[F], val asContext: AsContext[F, Int], val useContext: UseContext[F, Int] ) From 4bc32d68fe97c9bcc0bdd904ec3e846828a0bb64 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 22 Sep 2023 13:26:32 +0000 Subject: [PATCH 5/5] Update cats-effect to 3.5.1 --- project/Dependencies.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 3d0a60b..5d7369d 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -2,7 +2,7 @@ import sbt._ object Dependencies { lazy val catsCore = "org.typelevel" %% "cats-core" % "2.10.0" - lazy val catsEffect = "org.typelevel" %% "cats-effect" % "2.5.5" + lazy val catsEffect = "org.typelevel" %% "cats-effect" % "3.5.1" lazy val catsMtl = "org.typelevel" %% "cats-mtl-core" % "0.7.1" lazy val circeCore = "io.circe" %% "circe-core" % "0.14.6" lazy val circeLiteral =