Browse Source

tumblr-colossus added

mfirry 10 years ago
parent
commit
846f662b69

+ 8 - 0
frameworks/Scala/colossus/.gitignore

@@ -0,0 +1,8 @@
+target/
+project/target
+bin/
+logs/
+.cache
+.classpath
+.project
+/bin/

+ 26 - 0
frameworks/Scala/colossus/README.md

@@ -0,0 +1,26 @@
+#colossus Benchmarking Test
+
+### JSON Encoding Test
+
+* [JSON test source](src/main/scala/code/lib/WebServer.scala)
+
+## Infrastructure Software Versions
+The tests were run with:
+
+* [Java Oracle 1.8.0_25](http://www.oracle.com/technetwork/java/javase)
+* [colossus 0.6.1](http://tumblr.github.io/colossus/)
+
+## Test URLs
+### JSON Encoding Test
+
+http://localhost:9007/json
+
+### Plaintext Test
+
+http://localhost:9007/plaintext
+
+## How to run
+sbt 'oneJar'
+
+java -jar target/scala-2.11/colossus*one-jar.jar
+

+ 23 - 0
frameworks/Scala/colossus/benchmark_config.json

@@ -0,0 +1,23 @@
+{
+  "framework": "colossus",
+  "tests": [{
+    "default": {
+      "orm": "Raw",
+      "database_os": "Linux",
+      "setup_file": "setup",
+      "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "port": 9007,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "None",
+      "framework": "colossus",
+      "language": "Scala",
+      "platform": "Akka",
+      "webserver": "None",
+      "os": "Linux",
+      "display_name": "colossus",
+      "notes": ""
+    }
+  }]
+}

+ 14 - 0
frameworks/Scala/colossus/build.sbt

@@ -0,0 +1,14 @@
+name := """colossus-example"""
+
+version := "0.1.0"
+
+scalaVersion := "2.11.5"
+
+com.github.retronym.SbtOneJar.oneJarSettings
+
+mainClass in oneJar := Some("example.Main")
+
+libraryDependencies ++= Seq(
+  "com.tumblr" %% "colossus" % "0.6.1",
+  "net.liftweb" %% "lift-json" % "2.6-RC1"
+)

+ 3 - 0
frameworks/Scala/colossus/install.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+fw_depends java8 sbt

+ 1 - 0
frameworks/Scala/colossus/project/plugins.sbt

@@ -0,0 +1 @@
+addSbtPlugin("org.scala-sbt.plugins" % "sbt-onejar" % "0.8")

+ 9 - 0
frameworks/Scala/colossus/setup.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+source $IROOT/java8.installed
+export SBT_HOME=${IROOT}/sbt
+
+${SBT_HOME}/bin/sbt 'oneJar'
+
+java -jar target/scala-2.11/colossus*one-jar.jar
+

+ 38 - 0
frameworks/Scala/colossus/src/main/scala/example/Main.scala

@@ -0,0 +1,38 @@
+package example
+
+import java.util.Date
+import java.text.SimpleDateFormat
+
+import colossus._
+import service._
+import protocols.http._
+import UrlParsing._
+import HttpMethod._
+
+import net.liftweb.json._
+import JsonDSL._
+
+object Main extends App {
+
+  implicit val io_system = IOSystem()
+
+  Service.become[Http]("sample", 9007) {
+    case request @ Get on Root / "json" => {
+      val json = ("message" -> "Hello, World!")
+      val sdf = new SimpleDateFormat("EEE, MMM d yyyy HH:MM:ss z")
+      val v = request.ok(compact(render(json)))
+        .withHeader("Content-Type", "application/json")
+        .withHeader("Server", "Colossus")
+        .withHeader("Date", sdf.format(new Date()))
+      Callback.successful(v)
+    }
+    case request @ Get on Root / "plaintext" => {
+      val sdf = new SimpleDateFormat("EEE, MMM d yyyy HH:MM:ss z")
+      val res = request.ok("Hello, World!")
+        .withHeader("Content-Type", "text/plain")
+        .withHeader("Server", "Colossus")
+        .withHeader("Date", sdf.format(new Date()))
+      Callback.successful(res)
+    }
+  }
+}