diff --git a/build.sbt b/build.sbt index df26eaa74..a7ebc76f1 100644 --- a/build.sbt +++ b/build.sbt @@ -17,9 +17,7 @@ lazy val http4s = project .settings( libraryDependencies ++= Seq( Dependencies.Libraries.http4sDsl, - Dependencies.Libraries.http4sEmber, Dependencies.Libraries.http4sBlaze, - Dependencies.Libraries.http4sNetty, Dependencies.Libraries.http4sClient, Dependencies.Libraries.log4cats, Dependencies.Libraries.thrift, diff --git a/http4s/src/main/scala/com.snowplowanalytics.snowplow.collector.core/HttpServer.scala b/http4s/src/main/scala/com.snowplowanalytics.snowplow.collector.core/HttpServer.scala index e62b7322f..e792b7d10 100644 --- a/http4s/src/main/scala/com.snowplowanalytics.snowplow.collector.core/HttpServer.scala +++ b/http4s/src/main/scala/com.snowplowanalytics.snowplow.collector.core/HttpServer.scala @@ -1,27 +1,15 @@ package com.snowplowanalytics.snowplow.collector.core -import java.net.InetSocketAddress -import javax.net.ssl.SSLContext - -import io.netty.handler.ssl._ - -import org.typelevel.log4cats.Logger -import org.typelevel.log4cats.slf4j.Slf4jLogger - -import com.comcast.ip4s.{IpAddress, Port} - -import cats.implicits._ - import cats.effect.{Async, Resource} - +import cats.implicits._ import org.http4s.HttpApp -import org.http4s.server.Server -import org.http4s.ember.server.EmberServerBuilder import org.http4s.blaze.server.BlazeServerBuilder -import org.http4s.netty.server.NettyServerBuilder +import org.http4s.server.Server +import org.typelevel.log4cats.Logger +import org.typelevel.log4cats.slf4j.Slf4jLogger -import fs2.io.net.Network -import fs2.io.net.tls.TLSContext +import java.net.InetSocketAddress +import javax.net.ssl.SSLContext object HttpServer { @@ -29,37 +17,11 @@ object HttpServer { def build[F[_]: Async]( app: HttpApp[F], - interface: String, port: Int, secure: Boolean, networking: Config.Networking ): Resource[F, Server] = - sys.env.get("HTTP4S_BACKEND").map(_.toUpperCase()) match { - case Some("BLAZE") | None => buildBlazeServer[F](app, port, secure, networking) - case Some("EMBER") => buildEmberServer[F](app, interface, port, secure, networking) - case Some("NETTY") => buildNettyServer[F](app, port, secure, networking) - case Some(other) => throw new IllegalArgumentException(s"Unrecognized http4s backend $other") - } - - private def buildEmberServer[F[_]: Async]( - app: HttpApp[F], - interface: String, - port: Int, - secure: Boolean, - networking: Config.Networking - ) = { - implicit val network = Network.forAsync[F] - Resource.eval(Logger[F].info("Building ember server")) >> - EmberServerBuilder - .default[F] - .withHost(IpAddress.fromString(interface).get) - .withPort(Port.fromInt(port).get) - .withHttpApp(app) - .withIdleTimeout(networking.idleTimeout) - .withMaxConnections(networking.maxConnections) - .cond(secure, _.withTLS(TLSContext.Builder.forAsync.fromSSLContext(SSLContext.getDefault))) - .build - } + buildBlazeServer[F](app, port, secure, networking) private def buildBlazeServer[F[_]: Async]( app: HttpApp[F], @@ -76,40 +38,6 @@ object HttpServer { .cond(secure, _.withSslContext(SSLContext.getDefault)) .resource - private def buildNettyServer[F[_]: Async]( - app: HttpApp[F], - port: Int, - secure: Boolean, - networking: Config.Networking - ) = - Resource.eval(Logger[F].info("Building netty server")) >> - NettyServerBuilder[F] - .bindLocal(port) - .withHttpApp(app) - .withIdleTimeout(networking.idleTimeout) - .cond( - secure, - _.withSslContext( - new JdkSslContext( - SSLContext.getDefault, - false, - null, - IdentityCipherSuiteFilter.INSTANCE, - new ApplicationProtocolConfig( - ApplicationProtocolConfig.Protocol.ALPN, - ApplicationProtocolConfig.SelectorFailureBehavior.NO_ADVERTISE, - ApplicationProtocolConfig.SelectedListenerFailureBehavior.ACCEPT, - ApplicationProtocolNames.HTTP_2, - ApplicationProtocolNames.HTTP_1_1 - ), - ClientAuth.NONE, - null, - false - ) - ) - ) - .resource - implicit class ConditionalAction[A](item: A) { def cond(cond: Boolean, action: A => A): A = if (cond) action(item) else item diff --git a/http4s/src/main/scala/com.snowplowanalytics.snowplow.collector.core/Run.scala b/http4s/src/main/scala/com.snowplowanalytics.snowplow.collector.core/Run.scala index 944785107..443f40e2a 100644 --- a/http4s/src/main/scala/com.snowplowanalytics.snowplow.collector.core/Run.scala +++ b/http4s/src/main/scala/com.snowplowanalytics.snowplow.collector.core/Run.scala @@ -72,7 +72,6 @@ object Run { ) httpServer = HttpServer.build[F]( new Routes[F](config.enableDefaultRedirect, collectorService).value, - config.interface, if (config.ssl.enable) config.ssl.port else config.port, config.ssl.enable, config.networking diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 89c20c659..d1a4f7b2b 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -35,7 +35,6 @@ object Dependencies { val log4cats = "2.6.0" val http4s = "0.23.23" val blaze = "0.23.15" - val http4sNetty = "0.5.9" val decline = "2.4.1" val circe = "0.14.1" val circeConfig = "0.10.0" @@ -74,9 +73,7 @@ object Dependencies { // http4s val http4sDsl = "org.http4s" %% "http4s-dsl" % V.http4s - val http4sEmber = "org.http4s" %% "http4s-ember-server" % V.http4s val http4sBlaze = "org.http4s" %% "http4s-blaze-server" % V.blaze - val http4sNetty = "org.http4s" %% "http4s-netty-server" % V.http4sNetty val http4sClient = "org.http4s" %% "http4s-blaze-client" % V.blaze val decline = "com.monovore" %% "decline-effect" % V.decline val circeGeneric = "io.circe" %% "circe-generic" % V.circe