diff --git a/build.sbt b/build.sbt index a266f804..07e2867a 100644 --- a/build.sbt +++ b/build.sbt @@ -60,7 +60,7 @@ ThisBuild / githubWorkflowEnv ++= List("PGP_PASSPHRASE", "PGP_SECRET", "SONATYPE val Versions = new { val catsCore = "2.8.0" val catsEffect = "3.3.14" - val catsEffect2 = "2.5.5" + val catsEffect2 = "3.5.2" val circe = "0.14.6" val jsoniter = "2.21.4" val monix = "3.4.1" diff --git a/oauth2-cache-ce2/src/main/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProvider.scala b/oauth2-cache-ce2/src/main/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProvider.scala index b72e7b19..1c9b2f62 100644 --- a/oauth2-cache-ce2/src/main/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProvider.scala +++ b/oauth2-cache-ce2/src/main/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProvider.scala @@ -4,7 +4,6 @@ import cats.Monad import cats.data.OptionT import cats.effect.Clock import cats.effect.Concurrent -import cats.effect.concurrent.Semaphore import cats.syntax.all._ import com.ocadotechnology.sttp.oauth2.cache.ExpiringCache import com.ocadotechnology.sttp.oauth2.cache.ce2.CachingAccessTokenProvider.TokenWithExpirationTime @@ -15,6 +14,7 @@ import com.ocadotechnology.sttp.oauth2.Secret import java.time.Instant import scala.concurrent.duration.Duration +import cats.effect.std.Semaphore final class CachingAccessTokenProvider[F[_]: Monad: Clock]( delegate: AccessTokenProvider[F], diff --git a/oauth2-cache-ce2/src/main/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CatsRefExpiringCache.scala b/oauth2-cache-ce2/src/main/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CatsRefExpiringCache.scala index 2e744c14..ef79ecd0 100644 --- a/oauth2-cache-ce2/src/main/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CatsRefExpiringCache.scala +++ b/oauth2-cache-ce2/src/main/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CatsRefExpiringCache.scala @@ -2,7 +2,6 @@ package com.ocadotechnology.sttp.oauth2.cache.ce2 import cats.Monad import cats.data.OptionT -import cats.effect.concurrent.Ref import cats.effect.Clock import cats.effect.Sync import cats.implicits._ @@ -10,6 +9,7 @@ import com.ocadotechnology.sttp.oauth2.cache.ExpiringCache import com.ocadotechnology.sttp.oauth2.cache.ce2.CatsRefExpiringCache.Entry import java.time.Instant +import cats.effect.Ref final class CatsRefExpiringCache[F[_]: Monad: Clock, K, V] private (ref: Ref[F, Map[K, Entry[V]]]) extends ExpiringCache[F, K, V] { diff --git a/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProviderParallelSpec.scala b/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProviderParallelSpec.scala index fb761000..2adf4fbb 100644 --- a/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProviderParallelSpec.scala +++ b/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProviderParallelSpec.scala @@ -1,10 +1,7 @@ package com.ocadotechnology.sttp.oauth2.cache.ce2 import cats.FlatMap -import cats.effect.ContextShift import cats.effect.IO -import cats.effect.Timer -import cats.effect.concurrent.Ref import cats.syntax.all._ import com.ocadotechnology.sttp.oauth2.ClientCredentialsToken.AccessTokenResponse import com.ocadotechnology.sttp.oauth2.cache.ExpiringCache @@ -19,11 +16,12 @@ import org.scalatest.wordspec.AnyWordSpec import java.time.Instant import scala.concurrent.ExecutionContext import scala.concurrent.duration._ +import cats.effect.{ Ref, Temporal } class CachingAccessTokenProviderParallelSpec extends AnyWordSpec with Matchers { private val ec: ExecutionContext = ExecutionContext.global implicit lazy val cs: ContextShift[IO] = IO.contextShift(ec) - implicit val clock: Timer[IO] = IO.timer(ec) + implicit val clock: Temporal[IO] = IO.timer(ec) private val testScope: Option[Scope] = Scope.of("test-scope") private val token = AccessTokenResponse(Secret("secret"), None, 10.seconds, testScope) @@ -64,7 +62,7 @@ class CachingAccessTokenProviderParallelSpec extends AnyWordSpec with Matchers { override def get(key: K): F[Option[V]] = delegate.get(key) override def put(key: K, value: V, expirationTime: Instant): F[Unit] = - Timer[F].sleep(sleepDuration) *> delegate.put(key, value, expirationTime) + Temporal[F].sleep(sleepDuration) *> delegate.put(key, value, expirationTime) override def remove(key: K): F[Unit] = delegate.remove(key) } diff --git a/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProviderSpec.scala b/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProviderSpec.scala index 437020b1..fa6368d4 100644 --- a/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProviderSpec.scala +++ b/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CachingAccessTokenProviderSpec.scala @@ -1,9 +1,6 @@ package com.ocadotechnology.sttp.oauth2.cache.ce2 -import cats.effect.ContextShift import cats.effect.IO -import cats.effect.Timer -import cats.effect.concurrent.Ref import cats.effect.laws.util.TestContext import com.ocadotechnology.sttp.oauth2.ClientCredentialsToken.AccessTokenResponse import com.ocadotechnology.sttp.oauth2.Secret @@ -15,11 +12,12 @@ import org.scalatest.Assertion import scala.concurrent.duration._ import com.ocadotechnology.sttp.oauth2.AccessTokenProvider +import cats.effect.{ Ref, Temporal } class CachingAccessTokenProviderSpec extends AnyWordSpec with Matchers { implicit lazy val testContext: TestContext = TestContext.apply() implicit lazy val cs: ContextShift[IO] = IO.contextShift(testContext) - implicit lazy val ioTimer: Timer[IO] = testContext.timer[IO] + implicit lazy val ioTimer: Temporal[IO] = testContext.timer[IO] private val testScope: Option[Scope] = Scope.of("test-scope") private val token = AccessTokenResponse(Secret("secret"), None, 10.seconds, testScope) diff --git a/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CatsRefExpiringCacheSpec.scala b/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CatsRefExpiringCacheSpec.scala index 9ae0cae5..49ab85e1 100644 --- a/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CatsRefExpiringCacheSpec.scala +++ b/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/CatsRefExpiringCacheSpec.scala @@ -1,18 +1,17 @@ package com.ocadotechnology.sttp.oauth2.cache.ce2 import cats.effect.Clock -import cats.effect.ContextShift import cats.effect.IO -import cats.effect.Timer import cats.effect.laws.util.TestContext import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec import scala.concurrent.duration._ +import cats.effect.Temporal class CatsRefExpiringCacheSpec extends AnyWordSpec with Matchers { implicit lazy val testContext: TestContext = TestContext.apply() implicit lazy val cs: ContextShift[IO] = IO.contextShift(testContext) - implicit lazy val ioTimer: Timer[IO] = testContext.timer[IO] + implicit lazy val ioTimer: Temporal[IO] = testContext.timer[IO] private val someKey = "key" private val someValue = 1 diff --git a/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/TestAccessTokenProvider.scala b/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/TestAccessTokenProvider.scala index 376c657a..ae5816ef 100644 --- a/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/TestAccessTokenProvider.scala +++ b/oauth2-cache-ce2/src/test/scala/com/ocadotechnology/sttp/oauth2/cache/ce2/TestAccessTokenProvider.scala @@ -1,13 +1,13 @@ package com.ocadotechnology.sttp.oauth2.cache.ce2 import cats.Functor -import cats.effect.concurrent.Ref import cats.syntax.all._ import com.ocadotechnology.sttp.oauth2.ClientCredentialsToken import com.ocadotechnology.sttp.oauth2.Introspection import com.ocadotechnology.sttp.oauth2.Secret import com.ocadotechnology.sttp.oauth2.common.Scope import com.ocadotechnology.sttp.oauth2.AccessTokenProvider +import cats.effect.Ref trait TestAccessTokenProvider[F[_]] extends AccessTokenProvider[F] { def setToken(scope: Option[Scope], token: ClientCredentialsToken.AccessTokenResponse): F[Unit]