Skip to content

Commit

Permalink
Upgrade http4s & http4s-jdk-http-client (#290)
Browse files Browse the repository at this point in the history
* upgrade http4s to 1.0.0-M40

* upgrade http4s-jdk-http-client to 1.0.0-M9 (fixes smoke tests issues)
  • Loading branch information
gvolpe authored Sep 3, 2023
1 parent f4803d3 commit f32f0af
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 10 additions & 4 deletions modules/core/src/main/scala/trading/core/http/Ember.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand All @@ -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")
Expand All @@ -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] =
Expand All @@ -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] =
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion modules/x-qa/src/test/scala/smokey/Smokey.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(_))
Expand Down
10 changes: 7 additions & 3 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f32f0af

Please sign in to comment.