Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

Update cats-effect to 3.2.0 #169

Closed
wants to merge 4 commits into from
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 @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 =>
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[_]] {

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion project/ProjectPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

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