From b007f429f8c15d70d0774fd1c351628bc727be90 Mon Sep 17 00:00:00 2001 From: 47erbot Date: Mon, 26 Jul 2021 05:13:00 +0000 Subject: [PATCH 1/3] Applied Scalafix rule(s) github:typelevel/cats-effect/v3_0_0?sha=series/3.x --- .../fortysevendeg/smarthome/client/app/ClientApp.scala | 3 ++- .../fortysevendeg/smarthome/client/app/ClientBoot.scala | 3 ++- .../smarthome/client/common/LocationsGenerator.scala | 9 +++++---- .../smarthome/client/process/SmartHomeServiceApi.scala | 3 ++- .../fortysevendeg/smarthome/server/app/ServerApp.scala | 3 ++- .../server/process/SmartHomeServiceHandler.scala | 3 ++- .../smarthome/server/process/TemperatureReader.scala | 5 +++-- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/client/src/main/scala/com/fortysevendeg/smarthome/client/app/ClientApp.scala b/client/src/main/scala/com/fortysevendeg/smarthome/client/app/ClientApp.scala index 7deae3d..e5592f9 100644 --- a/client/src/main/scala/com/fortysevendeg/smarthome/client/app/ClientApp.scala +++ b/client/src/main/scala/com/fortysevendeg/smarthome/client/app/ClientApp.scala @@ -6,8 +6,9 @@ import com.fortysevendeg.smarthome.client.common._ import com.fortysevendeg.smarthome.client.common.Implicits._ import fs2.Stream import io.chrisdavenport.log4cats.Logger +import cats.effect.Temporal -class ClientProgram[F[_]: ConcurrentEffect: ContextShift: Timer] extends ClientBoot[F] { +class ClientProgram[F[_]: ConcurrentEffect: ContextShift: Temporal] extends ClientBoot[F] { def clientProgram(config: SmartHomeClientConfig)(implicit L: Logger[F]): Stream[F, ExitCode] = { for { diff --git a/client/src/main/scala/com/fortysevendeg/smarthome/client/app/ClientBoot.scala b/client/src/main/scala/com/fortysevendeg/smarthome/client/app/ClientBoot.scala index cc96a2f..4cb6500 100644 --- a/client/src/main/scala/com/fortysevendeg/smarthome/client/app/ClientBoot.scala +++ b/client/src/main/scala/com/fortysevendeg/smarthome/client/app/ClientBoot.scala @@ -9,8 +9,9 @@ import fs2.Stream import io.chrisdavenport.log4cats.Logger import io.chrisdavenport.log4cats.slf4j.Slf4jLogger import pureconfig.generic.auto._ +import cats.effect.Temporal -abstract class ClientBoot[F[_]: ConcurrentEffect: ContextShift: Timer] { +abstract class ClientBoot[F[_]: ConcurrentEffect: ContextShift: Temporal] { def smartHomeServiceApi(host: String, port: Int)(implicit L: Logger[F] diff --git a/client/src/main/scala/com/fortysevendeg/smarthome/client/common/LocationsGenerator.scala b/client/src/main/scala/com/fortysevendeg/smarthome/client/common/LocationsGenerator.scala index 6106994..8b6672b 100644 --- a/client/src/main/scala/com/fortysevendeg/smarthome/client/common/LocationsGenerator.scala +++ b/client/src/main/scala/com/fortysevendeg/smarthome/client/common/LocationsGenerator.scala @@ -1,6 +1,6 @@ package com.fortysevendeg.smarthome.client.common -import cats.effect.{Async, Timer} +import cats.effect.Async import cats.syntax.flatMap._ import com.fortysevendeg.smarthome.protocol.messages._ import fs2.Stream @@ -9,6 +9,7 @@ import io.chrisdavenport.log4cats.Logger import scala.concurrent.duration._ import scala.math.BigDecimal.RoundingMode import scala.util.Random +import cats.effect.Temporal trait GeoCalculator { private val AVERAGE_RADIUS_OF_EARTH_KM: Double = 6371d @@ -46,7 +47,7 @@ object LocationsGenerator extends GeoCalculator { calculateDistanceInMiles(startingPoint, destination) ) - def get[F[_]: Async: Logger: Timer]: Stream[F, Location] = + def get[F[_]: Async: Logger: Temporal]: Stream[F, Location] = Stream .iterateEval(startingLocation)(location => nextLocation(location)) .takeWhile(location => @@ -58,8 +59,8 @@ object LocationsGenerator extends GeoCalculator { ) .append(Stream.emit(Location(Some(destination), Some(destination), 0d)).covary[F]) - def nextLocation[F[_]: Async: Timer](location: Location): F[Location] = - Timer[F] + def nextLocation[F[_]: Async: Temporal](location: Location): F[Location] = + Temporal[F] .sleep(1.seconds) .flatMap(_ => Async[F].delay { diff --git a/client/src/main/scala/com/fortysevendeg/smarthome/client/process/SmartHomeServiceApi.scala b/client/src/main/scala/com/fortysevendeg/smarthome/client/process/SmartHomeServiceApi.scala index 0bf52da..44521b1 100644 --- a/client/src/main/scala/com/fortysevendeg/smarthome/client/process/SmartHomeServiceApi.scala +++ b/client/src/main/scala/com/fortysevendeg/smarthome/client/process/SmartHomeServiceApi.scala @@ -13,6 +13,7 @@ import io.chrisdavenport.log4cats.Logger import higherkindness.mu.rpc.ChannelForAddress import higherkindness.mu.rpc.channel.{ManagedChannelInterpreter, UsePlaintext} import io.grpc.{CallOptions, ManagedChannel} +import cats.effect.Temporal trait SmartHomeServiceApi[F[_]] { @@ -46,7 +47,7 @@ object SmartHomeServiceApi { clientRPC.comingBackMode(locations) } - def createInstance[F[_]: ContextShift: Logger: Timer]( + def createInstance[F[_]: ContextShift: Logger: Temporal]( hostname: String, port: Int, sslEnabled: Boolean = true diff --git a/server/src/main/scala/com/fortysevendeg/smarthome/server/app/ServerApp.scala b/server/src/main/scala/com/fortysevendeg/smarthome/server/app/ServerApp.scala index 39a4154..6404003 100644 --- a/server/src/main/scala/com/fortysevendeg/smarthome/server/app/ServerApp.scala +++ b/server/src/main/scala/com/fortysevendeg/smarthome/server/app/ServerApp.scala @@ -9,8 +9,9 @@ import com.fortysevendeg.smarthome.protocol.services._ import com.permutive.pubsub.producer.PubsubProducer import higherkindness.mu.rpc.server.{AddService, GrpcServer} import io.chrisdavenport.log4cats.Logger +import cats.effect.Temporal -class ServerProgram[F[_]: ConcurrentEffect: Timer] extends ServerBoot[F] { +class ServerProgram[F[_]: ConcurrentEffect: Temporal] extends ServerBoot[F] { override def serverProgram( config: SmartHomeServerConfig diff --git a/server/src/main/scala/com/fortysevendeg/smarthome/server/process/SmartHomeServiceHandler.scala b/server/src/main/scala/com/fortysevendeg/smarthome/server/process/SmartHomeServiceHandler.scala index e299034..9cd250f 100644 --- a/server/src/main/scala/com/fortysevendeg/smarthome/server/process/SmartHomeServiceHandler.scala +++ b/server/src/main/scala/com/fortysevendeg/smarthome/server/process/SmartHomeServiceHandler.scala @@ -7,8 +7,9 @@ import com.fortysevendeg.smarthome.protocol.messages._ import com.fortysevendeg.smarthome.protocol.services._ import fs2._ import io.chrisdavenport.log4cats.Logger +import cats.effect.Temporal -class SmartHomeServiceHandler[F[_]: Async: Logger: Timer: TemperatureReader: SmartHomeSupervisor] +class SmartHomeServiceHandler[F[_]: Async: Logger: Temporal: TemperatureReader: SmartHomeSupervisor] extends SmartHomeService[F] { val serviceName = "SmartHomeService" diff --git a/server/src/main/scala/com/fortysevendeg/smarthome/server/process/TemperatureReader.scala b/server/src/main/scala/com/fortysevendeg/smarthome/server/process/TemperatureReader.scala index a046ba5..6d4187f 100644 --- a/server/src/main/scala/com/fortysevendeg/smarthome/server/process/TemperatureReader.scala +++ b/server/src/main/scala/com/fortysevendeg/smarthome/server/process/TemperatureReader.scala @@ -9,18 +9,19 @@ import io.chrisdavenport.log4cats.Logger import scala.concurrent.duration._ import scala.math.BigDecimal.RoundingMode import scala.util.Random +import cats.effect.Temporal trait TemperatureReader[F[_]] { def sendSamples: Stream[F, Temperature] } object TemperatureReader { - implicit def instance[F[_]: Sync: Logger: Timer]: TemperatureReader[F] = + implicit def instance[F[_]: Sync: Logger: Temporal]: TemperatureReader[F] = new TemperatureReader[F] { val seed = Temperature(77d, Some(TemperatureUnit("Fahrenheit"))) def readTemperature(current: Temperature): F[Temperature] = - Timer[F] + Temporal[F] .sleep(1.second) .flatMap(_ => Sync[F].delay { From d788c90a5c99224f5a0eb5d3e5949b81c75c086f Mon Sep 17 00:00:00 2001 From: 47erbot Date: Mon, 26 Jul 2021 05:13:01 +0000 Subject: [PATCH 2/3] Update cats-effect to 3.2.0 --- project/ProjectPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index 7c3c471..183eac2 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -11,7 +11,7 @@ object ProjectPlugin extends AutoPlugin { object autoImport { lazy val V = new { - val catsEffect = "2.5.1" + val catsEffect = "3.2.0" val log4cats = "1.1.1" val logbackClassic = "1.2.4" val mu = "0.21.3" From ad7648eac209cd948a948030bd4cabe51badf0b4 Mon Sep 17 00:00:00 2001 From: 47erbot Date: Fri, 30 Jul 2021 05:09:03 +0000 Subject: [PATCH 3/3] Update cats-effect to 3.2.0 --- project/ProjectPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index 1227c44..3aa4c7a 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -11,7 +11,7 @@ object ProjectPlugin extends AutoPlugin { object autoImport { lazy val V = new { - val catsEffect = "2.5.2" + val catsEffect = "3.2.0" val log4cats = "1.1.1" val logbackClassic = "1.2.5" val mu = "0.21.3"