diff --git a/build.sbt b/build.sbt index a1fe477e..0024aee2 100644 --- a/build.sbt +++ b/build.sbt @@ -55,6 +55,7 @@ val commonSettings = List( Libraries.fs2Core.value, Libraries.kittens.value, Libraries.ip4sCore.value, + Libraries.log4catsNoop, Libraries.monocleCore.value, Libraries.catsLaws % Test, Libraries.monocleLaw % Test, diff --git a/modules/core/src/main/scala/trading/core/http/Ember.scala b/modules/core/src/main/scala/trading/core/http/Ember.scala index eaf88ec9..f0264f3b 100644 --- a/modules/core/src/main/scala/trading/core/http/Ember.scala +++ b/modules/core/src/main/scala/trading/core/http/Ember.scala @@ -4,6 +4,7 @@ import cats.effect.kernel.{ Async, Resource } import cats.effect.std.Console import cats.syntax.all.* import com.comcast.ip4s.* +import fs2.io.net.Network import org.http4s.* import org.http4s.ember.server.EmberServerBuilder import org.http4s.implicits.* @@ -12,12 +13,15 @@ import org.http4s.server.Server import org.http4s.server.middleware.Metrics import org.http4s.server.defaults.Banner import org.http4s.server.websocket.WebSocketBuilder +import org.typelevel.log4cats.LoggerFactory +import org.typelevel.log4cats.noop.NoOpFactory object Ember: private def showBanner[F[_]: Console](s: Server): F[Unit] = Console[F].println(s"\n${Banner.mkString("\n")}\nHTTP Server started at ${s.address}") - private def make[F[_]: Async](port: Port) = + private def make[F[_]: Async: Network](port: Port) = + given LoggerFactory[F] = NoOpFactory[F] EmberServerBuilder .default[F] .withHost(host"0.0.0.0") @@ -29,7 +33,7 @@ object Ember: ops <- Prometheus.metricsOps[F](prt.collectorRegistry) yield rts => Metrics[F](ops)(prt.routes <+> rts) - def websocket[F[_]: Async: Console]( + def websocket[F[_]: Async: Console: Network]( port: Port, f: WebSocketBuilder[F] => HttpRoutes[F] ): Resource[F, Server] = @@ -42,7 +46,7 @@ object Ember: .evalTap(showBanner[F]) } - def routes[F[_]: Async: Console]( + def routes[F[_]: Async: Console: Network]( port: Port, routes: HttpRoutes[F] ): Resource[F, Server] = @@ -53,7 +57,9 @@ object Ember: .evalTap(showBanner[F]) } - def default[F[_]: Async: Console](port: Port): Resource[F, Server] = + def default[F[_]: Async: Console: Network]( + port: Port + ): Resource[F, Server] = metrics[F].flatMap { mid => make[F](port) .withHttpApp(mid(HealthRoutes[F].routes).orNotFound) diff --git a/modules/x-qa/src/test/scala/smokey/Smokey.scala b/modules/x-qa/src/test/scala/smokey/Smokey.scala index 333ad757..7a34a641 100644 --- a/modules/x-qa/src/test/scala/smokey/Smokey.scala +++ b/modules/x-qa/src/test/scala/smokey/Smokey.scala @@ -14,6 +14,7 @@ import trading.lib.{ Producer, Shard } import trading.ws.* import cats.effect.* +import cats.effect.syntax.* import cats.syntax.all.* import dev.profunktor.pulsar.{ Config, Producer as PulsarProducer, Pulsar } import fs2.Stream @@ -31,7 +32,7 @@ object Smokey extends IOSuite: val connectReq = WSRequest(uri"ws://localhost:9000/v1/ws") override def sharedResource: Resource[IO, Res] = - (Pulsar.make[IO](pulsarCfg.url), JdkWSClient.simple[IO]).tupled + (Pulsar.make[IO](pulsarCfg.url), JdkWSClient.simple[IO].toResource).tupled val symbols1: List[WsIn] = List(EURUSD, USDCAD, GBPUSD).map(WsIn.Subscribe(_)) val symbols2: List[WsIn] = List(EURPLN, CHFEUR).map(WsIn.Subscribe(_)) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index d349c9f3..89053bbc 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -12,12 +12,13 @@ object Dependencies { val flyway = "8.5.13" val fs2Core = "3.9.1" val fs2Kafka = "3.0.1" - val http4s = "1.0.0-M39" + val http4s = "1.0.0-M40" val http4sMetrics = "1.0.0-M38" - val http4sWs = "1.0.0-M3" + val http4sWs = "1.0.0-M9" val ip4s = "3.3.0" val iron = "2.2.1" val kittens = "3.0.0" + val log4cats = "2.6.0" val monocle = "3.2.0" val natchez = "0.3.3" val natchezHttp4s = "0.5.0" @@ -30,7 +31,7 @@ object Dependencies { val tyrian = "0.6.1" val scalacheck = "1.17.0" - val weaver = "0.8.2" + val weaver = "0.8.3" val organizeImports = "0.6.0" val zerowaste = "0.2.12" @@ -82,6 +83,9 @@ object Dependencies { val odin = "com.github.valskalla" %% "odin-core" % V.odin + // only for ember + val log4catsNoop = "org.typelevel" %% "log4cats-noop" % V.log4cats + // webapp val scalajsTime = Def.setting("io.github.cquiroz" %%% "scala-java-time" % V.scalajsTime) val tyrian = Def.setting("io.indigoengine" %%% "tyrian" % V.tyrian)