diff --git a/neph.yaml b/neph.yaml index 220970d6cb0..875b175333e 100644 --- a/neph.yaml +++ b/neph.yaml @@ -94,6 +94,7 @@ cpp: scala: dependencies: - akkahttp + - http4s csharp: dependencies: @@ -344,6 +345,11 @@ akkahttp: - docker build -t akkahttp . directory: scala/akkahttp +http4s: + commands: + - docker build -t http4s . + directory: scala/http4s + aspnetcore: commands: - docker build -t aspnetcore . diff --git a/scala/http4s/.gitignore b/scala/http4s/.gitignore new file mode 100644 index 00000000000..d8ad3b567af --- /dev/null +++ b/scala/http4s/.gitignore @@ -0,0 +1,4 @@ +target/ +project/project +project/target +*.class diff --git a/scala/http4s/Dockerfile b/scala/http4s/Dockerfile new file mode 100644 index 00000000000..d03b938bef7 --- /dev/null +++ b/scala/http4s/Dockerfile @@ -0,0 +1,13 @@ +FROM bigtruedata/sbt + +WORKDIR /usr/src/app + +COPY build.sbt ./ +COPY src src +COPY project project + +RUN sbt assembly + +EXPOSE 3000 + +CMD java -jar target/scala-2.12/*assembly*.jar diff --git a/scala/http4s/build.sbt b/scala/http4s/build.sbt new file mode 100644 index 00000000000..5b6c3329b39 --- /dev/null +++ b/scala/http4s/build.sbt @@ -0,0 +1,15 @@ +val Http4sVersion = "0.18.17" + +lazy val root = (project in file(".")) + .settings( + organization := "the.benchmarker", + name := "http4s", + version := "0.0.1-SNAPSHOT", + scalaVersion := "2.12.6", + libraryDependencies ++= Seq( + "org.http4s" %% "http4s-blaze-server" % Http4sVersion, + "org.http4s" %% "http4s-circe" % Http4sVersion, + "org.http4s" %% "http4s-dsl" % Http4sVersion + ) + ) + diff --git a/scala/http4s/project/assembly.sbt b/scala/http4s/project/assembly.sbt new file mode 100644 index 00000000000..92636bc217f --- /dev/null +++ b/scala/http4s/project/assembly.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.4") \ No newline at end of file diff --git a/scala/http4s/project/build.properties b/scala/http4s/project/build.properties new file mode 100644 index 00000000000..6818e9c4481 --- /dev/null +++ b/scala/http4s/project/build.properties @@ -0,0 +1,2 @@ +sbt.version=0.13.15 + diff --git a/scala/http4s/src/main/scala/the/benchmarker/http4s/HelloWorldServer.scala b/scala/http4s/src/main/scala/the/benchmarker/http4s/HelloWorldServer.scala new file mode 100644 index 00000000000..0ebc26e2ed1 --- /dev/null +++ b/scala/http4s/src/main/scala/the/benchmarker/http4s/HelloWorldServer.scala @@ -0,0 +1,24 @@ +package the.benchmarker.http4s + +import cats.effect.{Effect, IO} +import fs2.StreamApp +import org.http4s.server.blaze.BlazeBuilder + +import scala.concurrent.ExecutionContext + +object HelloWorldServer extends StreamApp[IO] { + import scala.concurrent.ExecutionContext.Implicits.global + + def stream(args: List[String], requestShutdown: IO[Unit]) = ServerStream.stream[IO] +} + +object ServerStream { + + def helloWorldService[F[_]: Effect] = new HelloWorldService[F].service + + def stream[F[_]: Effect](implicit ec: ExecutionContext) = + BlazeBuilder[F] + .bindHttp(3000, "0.0.0.0") + .mountService(helloWorldService, "/") + .serve +} diff --git a/scala/http4s/src/main/scala/the/benchmarker/http4s/HelloWorldService.scala b/scala/http4s/src/main/scala/the/benchmarker/http4s/HelloWorldService.scala new file mode 100644 index 00000000000..237f65facee --- /dev/null +++ b/scala/http4s/src/main/scala/the/benchmarker/http4s/HelloWorldService.scala @@ -0,0 +1,20 @@ +package the.benchmarker.http4s + +import cats.effect.Effect +import io.circe.Json +import org.http4s.HttpService +import org.http4s.dsl.Http4sDsl + +class HelloWorldService[F[_]: Effect] extends Http4sDsl[F] { + + val service: HttpService[F] = { + HttpService[F] { + case GET -> Root => + Ok("") + case POST -> Root / "user" => + Ok("") + case GET -> Root / "user" / name => + Ok(name) + } + } +} diff --git a/tools/src/benchmarker.cr b/tools/src/benchmarker.cr index 7ad3281fdba..54c6ede231a 100644 --- a/tools/src/benchmarker.cr +++ b/tools/src/benchmarker.cr @@ -98,6 +98,7 @@ LANGS = [ ]}, {lang: "scala", targets: [ {name: "akkahttp", repo: "akka/akka-http"}, + {name: "http4s", repo: "http4s/http4s"}, ]}, {lang: "csharp", targets: [ {name: "aspnetcore", repo: "aspnet/Home"},