Browse Source

Merge pull request #1582 from mfirry/master

Scala: Add Colossus
Hamilton Turner 10 years ago
parent
commit
1a798e43f1

+ 11 - 10
.travis.yml

@@ -1,5 +1,5 @@
 language: python
-python: 
+python:
   - "2.7"
 
 env:
@@ -9,12 +9,12 @@ env:
     # we end up starting ~200+ different workers. Seems that ~100 is the limit
     # before their website starts to lag heavily
     #
-    # Here's the bash if you need to update this. Be sure to maintain the 
+    # Here's the bash if you need to update this. Be sure to maintain the
     # lines that are currently commented out (these cannot run in Travis)
-    #   cd frameworks 
+    #   cd frameworks
     #   find . -type d -depth 2 | sed 's|./|    - "TESTDIR=|' | sed 's/$/"/g'
     #
-    #  
+    #
     - "TESTDIR=C/lwan"
     - "TESTDIR=C/duda"
     - "TESTDIR=C/haywire"
@@ -142,6 +142,7 @@ env:
     - "TESTDIR=Ruby/rails"
     - "TESTDIR=Ruby/rails-stripped"
     - "TESTDIR=Ruby/sinatra"
+    - "TESTDIR=Scala/colossus"
     - "TESTDIR=Scala/finagle"
     - "TESTDIR=Scala/lift-stateless"
     - "TESTDIR=Scala/plain"
@@ -155,7 +156,7 @@ env:
     - "TESTDIR=Ur/urweb"
 
 before_install:
-  # Need to install python modules before using 
+  # Need to install python modules before using
   # python
   - pip install -r requirements.txt
 
@@ -164,15 +165,15 @@ before_install:
   - ./toolset/run-ci.py cisetup "$TESTDIR"
 
 addons:
-  postgresql: "9.3" 
+  postgresql: "9.3"
 
 install:
   # Install prerequisites
   - ./toolset/run-ci.py prereq "$TESTDIR"
-  
-  # Install software for this framework  
+
+  # Install software for this framework
   - ./toolset/run-ci.py install "$TESTDIR"
-   
-script: 
+
+script:
   # Pick one test in this directory and verify
   - time ./toolset/run-ci.py verify "$TESTDIR"

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

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

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

@@ -0,0 +1,30 @@
+#colossus Benchmarking Test
+
+### JSON Encoding Test
+
+* [JSON test source](src/main/scala/example/Main.scala)
+
+### Plaintext Test
+
+* [JSON test source](src/main/scala/example/Main.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)
+    }
+  }
+}