From e193f8bfa2abd57f562e906f6cdd272a0759fd5c Mon Sep 17 00:00:00 2001 From: Ilya Surkov Date: Tue, 27 Jun 2023 15:21:15 +0200 Subject: [PATCH] Bump smetrics, cats-helper, deprecate legacy MeasureDuration usages --- .../cluster/sharding/ClusterSharding.scala | 22 +++++++++++++++++-- .../sharding/ClusterShardingTest.scala | 2 +- .../akkaeffect/eventsourcing/Journaller.scala | 14 +++++++++--- .../akkaeffect/persistence/Append.scala | 14 +++++++++--- .../persistence/DeleteEventsTo.scala | 13 +++++++++-- .../akkaeffect/persistence/Journaller.scala | 20 ++++++++++++----- .../akkaeffect/persistence/Snapshotter.scala | 15 +++++++++---- project/Dependencies.scala | 4 ++-- version.sbt | 2 +- 9 files changed, 82 insertions(+), 24 deletions(-) diff --git a/cluster-sharding/src/main/scala/com/evolutiongaming/akkaeffect/cluster/sharding/ClusterSharding.scala b/cluster-sharding/src/main/scala/com/evolutiongaming/akkaeffect/cluster/sharding/ClusterSharding.scala index bfaa8e25..91990a18 100644 --- a/cluster-sharding/src/main/scala/com/evolutiongaming/akkaeffect/cluster/sharding/ClusterSharding.scala +++ b/cluster-sharding/src/main/scala/com/evolutiongaming/akkaeffect/cluster/sharding/ClusterSharding.scala @@ -13,7 +13,7 @@ import com.evolutiongaming.akkaeffect.util.Terminated import com.evolutiongaming.akkaeffect.{ActorRefOf, Ask} import com.evolutiongaming.catshelper.CatsHelper._ import com.evolutiongaming.catshelper._ -import com.evolutiongaming.smetrics.MeasureDuration +import com.evolutiongaming.smetrics import scala.concurrent.duration._ @@ -138,15 +138,33 @@ object ClusterSharding { implicit class ClusterShardingOps[F[_]](val self: ClusterSharding[F]) extends AnyVal { + @deprecated("Use `withLogging1` instead", "2.1.0") def withLogging(implicit + F: BracketThrowable[F], + measureDuration: smetrics.MeasureDuration[F], + logOf: LogOf[F] + ): F[ClusterSharding[F]] = { + withLogging1(F, measureDuration.toCatsHelper, logOf) + } + + def withLogging1(implicit F: BracketThrowable[F], measureDuration: MeasureDuration[F], logOf: LogOf[F] ): F[ClusterSharding[F]] = { - logOf(ClusterSharding.getClass).map { log => withLogging(log) } + logOf(ClusterSharding.getClass).map { log => withLogging1(log) } } + @deprecated("Use `withLogging1` instead", "2.1.0") def withLogging( + log: Log[F])(implicit + F: BracketThrowable[F], + measureDuration: smetrics.MeasureDuration[F] + ): ClusterSharding[F] = { + withLogging1(log)(F, measureDuration.toCatsHelper) + } + + def withLogging1( log: Log[F])(implicit F: BracketThrowable[F], measureDuration: MeasureDuration[F] diff --git a/cluster-sharding/src/test/scala/com/evolutiongaming/akkaeffect/cluster/sharding/ClusterShardingTest.scala b/cluster-sharding/src/test/scala/com/evolutiongaming/akkaeffect/cluster/sharding/ClusterShardingTest.scala index f3f7014d..ded4f978 100644 --- a/cluster-sharding/src/test/scala/com/evolutiongaming/akkaeffect/cluster/sharding/ClusterShardingTest.scala +++ b/cluster-sharding/src/test/scala/com/evolutiongaming/akkaeffect/cluster/sharding/ClusterShardingTest.scala @@ -34,7 +34,7 @@ class ClusterShardingTest extends AsyncFunSuite with ActorSuite with Matchers { logOf <- LogOf.slf4j[IO].toResource log <- logOf(classOf[ClusterShardingTest]).toResource clusterSharding <- ClusterSharding.of[IO](actorSystem) - clusterSharding <- clusterSharding.withLogging(log).pure[Resource[IO, *]] + clusterSharding <- clusterSharding.withLogging1(log).pure[Resource[IO, *]] clusterShardingSettings <- IO { ClusterShardingSettings(actorSystem) }.toResource actorRefOf = ActorRefOf.fromActorRefFactory[IO](actorSystem) probe <- Probe.of[IO](actorRefOf) diff --git a/eventsourcing/src/main/scala/com/evolutiongaming/akkaeffect/eventsourcing/Journaller.scala b/eventsourcing/src/main/scala/com/evolutiongaming/akkaeffect/eventsourcing/Journaller.scala index fddb5450..13309eaa 100644 --- a/eventsourcing/src/main/scala/com/evolutiongaming/akkaeffect/eventsourcing/Journaller.scala +++ b/eventsourcing/src/main/scala/com/evolutiongaming/akkaeffect/eventsourcing/Journaller.scala @@ -4,8 +4,8 @@ import cats.syntax.all._ import cats.{Applicative, FlatMap, Functor, ~>} import com.evolutiongaming.akkaeffect.persistence import com.evolutiongaming.akkaeffect.persistence.SeqNr -import com.evolutiongaming.catshelper.Log -import com.evolutiongaming.smetrics.MeasureDuration +import com.evolutiongaming.catshelper.{Log, MeasureDuration} +import com.evolutiongaming.smetrics trait Journaller[F[_]] { @@ -35,8 +35,16 @@ object Journaller { (seqNr: SeqNr) => f(self.deleteTo(seqNr)).map(a => f(a)) } - + @deprecated("Use `withLogging1` instead", "2.1.0") def withLogging( + log: Log[F])(implicit + F: FlatMap[F], + measureDuration: smetrics.MeasureDuration[F] + ): Journaller[F] = { + withLogging1(log)(F, measureDuration.toCatsHelper) + } + + def withLogging1( log: Log[F])(implicit F: FlatMap[F], measureDuration: MeasureDuration[F] diff --git a/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Append.scala b/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Append.scala index 2a171fcb..abe6d619 100644 --- a/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Append.scala +++ b/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Append.scala @@ -8,8 +8,8 @@ import cats.{Applicative, FlatMap, Monad, ~>} import com.evolutiongaming.akkaeffect.util.AtomicRef import com.evolutiongaming.akkaeffect.{Act, Fail} import com.evolutiongaming.catshelper.CatsHelper._ -import com.evolutiongaming.catshelper.{Log, MonadThrowable, ToFuture} -import com.evolutiongaming.smetrics.MeasureDuration +import com.evolutiongaming.catshelper.{Log, MeasureDuration, MonadThrowable, ToFuture} +import com.evolutiongaming.smetrics import scala.collection.immutable.Queue @@ -144,8 +144,16 @@ object Append { def narrow[B <: A]: Append[F, B] = events => self(events) - + @deprecated("Use `withLogging1` instead", "2.1.0") def withLogging( + log: Log[F])(implicit + F: FlatMap[F], + measureDuration: smetrics.MeasureDuration[F] + ): Append[F, A] = { + withLogging1(log)(F, measureDuration.toCatsHelper) + } + + def withLogging1( log: Log[F])(implicit F: FlatMap[F], measureDuration: MeasureDuration[F] diff --git a/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/DeleteEventsTo.scala b/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/DeleteEventsTo.scala index 7fe3cfc9..ee5b8dcb 100644 --- a/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/DeleteEventsTo.scala +++ b/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/DeleteEventsTo.scala @@ -5,8 +5,8 @@ import cats.effect.{Resource, Sync} import cats.syntax.all._ import cats.{Applicative, FlatMap, ~>} import com.evolutiongaming.akkaeffect.Fail -import com.evolutiongaming.catshelper.{FromFuture, Log, MonadThrowable} -import com.evolutiongaming.smetrics.MeasureDuration +import com.evolutiongaming.catshelper.{FromFuture, Log, MeasureDuration, MonadThrowable} +import com.evolutiongaming.smetrics import scala.concurrent.duration.FiniteDuration @@ -56,7 +56,16 @@ object DeleteEventsTo { } } + @deprecated("Use `withLogging1` instead", "2.1.0") def withLogging( + log: Log[F])(implicit + F: FlatMap[F], + measureDuration: smetrics.MeasureDuration[F] + ): DeleteEventsTo[F] = { + withLogging1(log)(F, measureDuration.toCatsHelper) + } + + def withLogging1( log: Log[F])(implicit F: FlatMap[F], measureDuration: MeasureDuration[F] diff --git a/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Journaller.scala b/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Journaller.scala index b1a6e6bc..9553c389 100644 --- a/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Journaller.scala +++ b/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Journaller.scala @@ -2,8 +2,8 @@ package com.evolutiongaming.akkaeffect.persistence import cats.{Applicative, FlatMap, Monad, ~>} import com.evolutiongaming.akkaeffect.Fail -import com.evolutiongaming.catshelper.{Log, MonadThrowable} -import com.evolutiongaming.smetrics.MeasureDuration +import com.evolutiongaming.catshelper.{Log, MeasureDuration, MonadThrowable} +import com.evolutiongaming.smetrics /** @@ -31,7 +31,7 @@ object Journaller { def empty[F[_]: Applicative, A]: Journaller[F, A] = { Journaller(Append.empty[F, A], DeleteEventsTo.empty[F]) } - + def apply[F[_], A]( append: Append[F, A], @@ -90,15 +90,23 @@ object Journaller { } } - + @deprecated("Use `withLogging1` instead", "2.1.0") def withLogging( + log: Log[F])(implicit + F: FlatMap[F], + measureDuration: smetrics.MeasureDuration[F] + ): Journaller[F, A] = { + withLogging1(log)(F, measureDuration.toCatsHelper) + } + + def withLogging1( log: Log[F])(implicit F: FlatMap[F], measureDuration: MeasureDuration[F] ): Journaller[F, A] = { Journaller( - self.append.withLogging(log), - self.deleteTo.withLogging(log)) + self.append.withLogging1(log), + self.deleteTo.withLogging1(log)) } diff --git a/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Snapshotter.scala b/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Snapshotter.scala index a5f88b9d..6e4329ed 100644 --- a/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Snapshotter.scala +++ b/persistence/src/main/scala/com/evolutiongaming/akkaeffect/persistence/Snapshotter.scala @@ -1,14 +1,13 @@ package com.evolutiongaming.akkaeffect.persistence import java.time.Instant - import akka.persistence.{SnapshotSelectionCriteria, Snapshotter => _, _} import cats.effect.Sync import cats.syntax.all._ import cats.{Applicative, FlatMap, ~>} import com.evolutiongaming.akkaeffect.Fail -import com.evolutiongaming.catshelper.{FromFuture, Log, MonadThrowable} -import com.evolutiongaming.smetrics.MeasureDuration +import com.evolutiongaming.catshelper.{FromFuture, Log, MeasureDuration, MonadThrowable} +import com.evolutiongaming.smetrics import scala.concurrent.duration.FiniteDuration @@ -95,8 +94,16 @@ object Snapshotter { } } - + @deprecated("Use `withLogging1` instead", "2.1.0") def withLogging( + log: Log[F])(implicit + F: FlatMap[F], + measureDuration: smetrics.MeasureDuration[F] + ): Snapshotter[F, A] = { + withLogging1(log)(F, measureDuration.toCatsHelper) + } + + def withLogging1( log: Log[F])(implicit F: FlatMap[F], measureDuration: MeasureDuration[F] diff --git a/project/Dependencies.scala b/project/Dependencies.scala index f695e7c4..502f510e 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -3,13 +3,13 @@ import sbt._ object Dependencies { val scalatest = "org.scalatest" %% "scalatest" % "3.2.15" - val `cats-helper` = "com.evolutiongaming" %% "cats-helper" % "3.4.0" + val `cats-helper` = "com.evolutiongaming" %% "cats-helper" % "3.6.0" val `executor-tools` = "com.evolutiongaming" %% "executor-tools" % "1.0.4" val retry = "com.evolutiongaming" %% "retry" % "3.0.1" val `akka-persistence-inmemory` = "com.github.dnvriend" %% "akka-persistence-inmemory" % "2.5.15.2" val `kind-projector` = "org.typelevel" % "kind-projector" % "0.13.2" val pureconfig = "com.github.pureconfig" %% "pureconfig" % "0.17.3" - val smetrics = "com.evolutiongaming" %% "smetrics" % "1.0.6" + val smetrics = "com.evolutiongaming" %% "smetrics" % "1.3.0" object Cats { private val version = "2.9.0" diff --git a/version.sbt b/version.sbt index 14cae958..75bf8c98 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -ThisBuild / version := "2.0.1-SNAPSHOT" +ThisBuild / version := "2.1.0-SNAPSHOT"