Browse Source

Merge remote-tracking branch 'upstream/master'

MTD 9 years ago
parent
commit
d6a22d508b
29 changed files with 154 additions and 150 deletions
  1. 1 1
      frameworks/Elixir/phoenix/config/dev.exs
  2. 4 5
      frameworks/Elixir/phoenix/config/prod.exs
  3. 2 1
      frameworks/Elixir/phoenix/lib/hello/endpoint.ex
  4. 9 9
      frameworks/Elixir/phoenix/mix.exs
  5. 2 3
      frameworks/Elixir/phoenix/setup.sh
  6. 17 11
      frameworks/Elixir/phoenix/web/controllers/page_controller.ex
  7. 1 0
      frameworks/Elixir/phoenix/web/models/fortune.ex
  8. 3 2
      frameworks/Elixir/phoenix/web/models/world.ex
  9. 0 18
      frameworks/Elixir/phoenix/web/router.ex
  10. 0 0
      frameworks/Elixir/phoenix/web/templates/layout/app.html.eex
  11. 2 1
      frameworks/Elixir/phoenix/web/web.ex
  12. 4 5
      frameworks/Java/spring/README.md
  13. 21 12
      frameworks/Java/spring/pom.xml
  14. 1 1
      frameworks/Java/spring/source_code
  15. 27 34
      frameworks/Java/spring/src/main/java/com/techempower/spring/web/WorldDatabaseController.java
  16. 1 0
      frameworks/Java/spring/src/main/resources/application.yml
  17. 7 7
      frameworks/Java/wildfly-ee7/pom.xml
  18. 1 1
      frameworks/Java/wildfly-ee7/setup.sh
  19. 3 2
      frameworks/Python/cherrypy/app.py
  20. 0 3
      frameworks/Python/cherrypy/requirements.txt
  21. 2 2
      frameworks/Python/historical/webware/app/Context/fortune.py
  22. 0 1
      frameworks/Python/historical/webware/requirements.txt
  23. 17 7
      frameworks/Python/wheezyweb/app.py
  24. 0 2
      frameworks/Python/wheezyweb/requirements.txt
  25. 1 1
      frameworks/Python/wheezyweb/views/fortune.html
  26. 7 4
      frameworks/Scala/finch/build.sbt
  27. 19 15
      frameworks/Scala/finch/src/main/scala/WebServer.scala
  28. 1 1
      toolset/setup/linux/languages/elixir.sh
  29. 1 1
      toolset/setup/linux/languages/erlang.sh

+ 1 - 1
frameworks/Elixir/phoenix/config/dev.exs

@@ -23,7 +23,7 @@ config :hello, Hello.Endpoint,
   ]
 
 config :hello, Hello.Repo,
-  adapter: Ecto.Adapters.MySQL,
+  adapter: Ecto.Adapters.Postgres,
   username: "benchmarkdbuser",
   password: "benchmarkdbpass",
   database: "hello_world",

+ 4 - 5
frameworks/Elixir/phoenix/config/prod.exs

@@ -7,11 +7,12 @@ config :hello, Hello.Endpoint,
   server: true
 
 config :hello, Hello.Repo,
-  adapter: Ecto.Adapters.MySQL,
+  adapter: Ecto.Adapters.Postgres,
   username: "benchmarkdbuser",
   password: "benchmarkdbpass",
   database: "hello_world",
-  hostname: "localhost"
+  hostname: "192.168.56.101",
+  pool_size: 256
 
 # ## SSL Support
 #
@@ -27,9 +28,7 @@ config :hello, Hello.Repo,
 # Where those two env variables point to a file on
 # disk for the key and cert.
 
-
-# Do not pring debug messages in production
-config :logger, level: :info
+config :logger, level: :error
 
 # ## Using releases
 #

+ 2 - 1
frameworks/Elixir/phoenix/lib/hello/endpoint.ex

@@ -9,6 +9,7 @@ defmodule Hello.Endpoint do
   # Code reloading will only work if the :code_reloader key of
   # the :phoenix application is set to true in your config file.
   if code_reloading? do
+    socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
     plug Phoenix.LiveReloader
     plug Phoenix.CodeReloader
   end
@@ -28,5 +29,5 @@ defmodule Hello.Endpoint do
     key: "_hello_key",
     signing_salt: "DNlAnJ2o"
 
-  plug :router, Hello.Router
+  plug Hello.Router
 end

+ 9 - 9
frameworks/Elixir/phoenix/mix.exs

@@ -4,7 +4,7 @@ defmodule Hello.Mixfile do
   def project do
    [app: :hello,
     version: "0.0.1",
-    elixir: "~> 1.0",
+    elixir: "~> 1.1",
     elixirc_paths: elixirc_paths(Mix.env),
     compilers: [:phoenix] ++ Mix.compilers,
     build_embedded: Mix.env == :prod,
@@ -17,7 +17,7 @@ defmodule Hello.Mixfile do
   # Type `mix help compile.app` for more information
   def application do
     [mod: {Hello, []},
-     applications: [:phoenix, :phoenix_ecto, :mariaex, :cowboy, :logger, :phoenix_html]]
+     applications: [:phoenix, :phoenix_ecto, :postgrex, :cowboy, :logger, :phoenix_html]]
   end
 
   defp elixirc_paths(_), do: ["lib", "web"]
@@ -26,12 +26,12 @@ defmodule Hello.Mixfile do
   #
   # Type `mix help deps` for examples and options
   defp deps do
-    [{:phoenix, "~> 0.13.1"},
-     {:phoenix_ecto, "~> 0.4"},
-     {:mariaex, "~> 0.3.0"},
-     {:cowboy, "~> 1.0"},
-     {:phoenix_html, "~> 1.0"},
-     {:phoenix_live_reload, "~> 0.4", only: :dev},
-     {:exrm, "~> 0.15.3"}]
+    [{:phoenix, "~> 1.0.3"},
+     {:phoenix_ecto, "~> 1.1"},
+     {:postgrex, ">= 0.0.0"},
+     {:cowboy, "~> 1.0.0"},
+     {:phoenix_html, "~> 2.1"},
+     {:phoenix_live_reload, "~> 1.0", only: :dev},
+     {:exrm, "~> 0.19.8"}]
   end
 end

+ 2 - 3
frameworks/Elixir/phoenix/setup.sh

@@ -4,10 +4,9 @@ fw_depends elixir
 
 sed -i 's|localhost|'${DBHOST}'|g' config/prod.exs
 
-rm -rf _build deps rel
+rm -rf _build deps
 
-MIX_ENV=prod
-export MIX_ENV
+export MIX_ENV=prod
 mix local.hex --force
 mix deps.get --force
 mix compile --force

+ 17 - 11
frameworks/Elixir/phoenix/web/controllers/page_controller.ex

@@ -4,8 +4,6 @@ defmodule Hello.PageController do
   alias Hello.Fortune
 
   plug :action
-  plug :scrub_params, "world" when action in [:create, :update]
-
 
   def index(conn, _params) do
     json conn, %{"TE Benchmarks\n" => "Started"}
@@ -21,10 +19,14 @@ defmodule Hello.PageController do
   end
 
   def queries(conn, _params) do
-    q = case String.to_integer(_params["queries"]) do
-      x when x < 1    -> 1
-      x when x > 500  -> 500
-      x               -> x
+    q = try do
+      case String.to_integer(_params["queries"]) do
+        x when x < 1    -> 1
+        x when x > 500  -> 500
+        x               -> x
+      end
+    rescue
+      ArgumentError -> 1
     end
     json conn, Enum.map(1..q, fn _ -> Repo.get(World, :random.uniform(10000)) end)
   end
@@ -35,17 +37,21 @@ defmodule Hello.PageController do
   end
 
   def updates(conn, _params) do
-    q = case String.to_integer(_params["queries"]) do
-      x when x < 1    -> 1
-      x when x > 500  -> 500
-      x               -> x
+    q = try do
+      case String.to_integer(_params["queries"]) do
+        x when x < 1    -> 1
+        x when x > 500  -> 500
+        x               -> x
+      end
+    rescue
+      ArgumentError -> 1
     end
     json conn, Enum.map(1..q, fn _ ->
       w = Repo.get(World, :random.uniform(10000))
       changeset = World.changeset(w, %{randomNumber: :random.uniform(10000)})
       Repo.update(changeset)
       w end)
-    end
+  end
 
   def plaintext(conn, _params) do
     text conn, "Hello, world!"

+ 1 - 0
frameworks/Elixir/phoenix/web/models/fortune.ex

@@ -1,6 +1,7 @@
 defmodule Hello.Fortune do
   use Hello.Web, :model
 
+  @derive {Poison.Encoder, only: [:id, :message]}
   schema "fortune" do
     field :message, :string
   end

+ 3 - 2
frameworks/Elixir/phoenix/web/models/world.ex

@@ -1,11 +1,12 @@
 defmodule Hello.World do
   use Hello.Web, :model
 
+  @derive {Poison.Encoder, only: [:id, :randomnumber]}
   schema "world" do
-    field :randomNumber, :integer
+    field :randomnumber, :integer
   end
 
-  @required_fields ~w(randomNumber)
+  @required_fields ~w(randomnumber)
   @optional_fields ~w()
 
   def changeset(model, params \\ nil) do

+ 0 - 18
frameworks/Elixir/phoenix/web/router.ex

@@ -1,20 +1,7 @@
 defmodule Hello.Router do
   use Hello.Web, :router
 
-  pipeline :browser do
-    plug :accepts, ["html"]
-    plug :fetch_session
-    plug :fetch_flash
-    plug :protect_from_forgery
-  end
-
-  pipeline :api do
-    plug :accepts, ["json"]
-  end
-
   scope "/", Hello do
-    pipe_through :browser # Use the default browser stack
-
     get "/json", PageController, :_json
     get "/db", PageController, :db
     get "/queries", PageController, :queries
@@ -23,9 +10,4 @@ defmodule Hello.Router do
     get "/plaintext", PageController, :plaintext
     get "/", PageController, :index
   end
-
-  # Other scopes may use custom stacks.
-  # scope "/api", Hello do
-  #   pipe_through :api
-  # end
 end

+ 0 - 0
frameworks/Elixir/phoenix/web/templates/layout/application.html.eex → frameworks/Elixir/phoenix/web/templates/layout/app.html.eex


+ 2 - 1
frameworks/Elixir/phoenix/web/web.ex

@@ -37,7 +37,8 @@ defmodule Hello.Web do
       use Phoenix.View, root: "web/templates"
 
       # Import convenience functions from controllers
-      import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1]
+      import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2,
+                                        action_name: 1, controller_module: 1]
 
       # Import URL helpers from the router
       import Hello.Router.Helpers

+ 4 - 5
frameworks/Java/spring/README.md

@@ -61,8 +61,7 @@ Check out [SampleApplication, the main Application file](src/main/java/com/teche
 ## Infrastructure Software Versions
 The tests were run with:
 
-* [Spring 4.1.4.RELEASE](http://projects.spring.io/spring-framework/)
-* [Spring Boot 1.2.1.RELEASE](http://projects.spring.io/spring-boot/)
-* [Spring Data JPA 1.7.1.RELEASE](http://projects.spring.io/spring-data-jpa/)
-* [Java OpenJDK 1.7.0_09](http://openjdk.java.net/)
-* [Undertow 1.1.1.Final](http://undertow.io/)
+* [Spring 4.1.7.RELEASE](http://projects.spring.io/spring-framework/)
+* [Spring Boot 1.2.5.RELEASE](http://projects.spring.io/spring-boot/)
+* [Spring Data JPA 1.7.3.RELEASE](http://projects.spring.io/spring-data-jpa/)
+* [Undertow 1.1.7.Final](http://undertow.io/)

+ 21 - 12
frameworks/Java/spring/pom.xml

@@ -8,7 +8,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>1.2.1.RELEASE</version>
+        <version>1.2.5.RELEASE</version>
     </parent>
 
     <groupId>com.techempower</groupId>
@@ -22,19 +22,10 @@
     </properties>
 
     <dependencies>
-        <dependency>
-            <groupId>com.h2database</groupId>
-            <artifactId>h2</artifactId>
-            <scope>runtime</scope>
-        </dependency>
         <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
         </dependency>
-        <dependency>
-            <groupId>com.zaxxer</groupId>
-            <artifactId>HikariCP</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-jpa</artifactId>
@@ -54,8 +45,8 @@
         	<artifactId>spring-boot-starter-undertow</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.thymeleaf</groupId>
-            <artifactId>thymeleaf-spring4</artifactId>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
         </dependency>
     </dependencies>
 
@@ -76,4 +67,22 @@
             <url>https://jcenter.bintray.com</url>
         </repository>
     </repositories>
+
+    <profiles>
+        <profile>
+            <id>local</id>
+            <activation>
+                <property>
+                    <name>env.SPRING_PROFILES_ACTIVE</name>
+                    <value>local</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>com.h2database</groupId>
+                    <artifactId>h2</artifactId>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
 </project>

+ 1 - 1
frameworks/Java/spring/source_code

@@ -6,7 +6,7 @@
 ./spring/src/main/java/com/techempower/spring/web/FortuneController.java
 ./spring/src/main/java/com/techempower/spring/web/HelloController.java
 ./spring/src/main/java/com/techempower/spring/web/WorldDatabaseController.java
+./spring/src/main/java/com/techempower/spring/Common.java
 ./spring/src/main/resources/application.yml
 ./spring/src/main/resources/logback.xml
-./spring/src/main/resources/schema.sql
 ./spring/src/main/resources/templates/fortunes.html

+ 27 - 34
frameworks/Java/spring/src/main/java/com/techempower/spring/web/WorldDatabaseController.java

@@ -29,8 +29,7 @@ final class WorldDatabaseController {
 
 	@RequestMapping(value = "/db", produces = "application/json")
 	World singleQuery() {
-		final Random random = ThreadLocalRandom.current();
-		return this.worldRepository.findOne(random.nextInt(DB_ROWS) + 1);
+		return this.worldRepository.findOne(ThreadLocalRandom.current().nextInt(DB_ROWS) + 1);
 	}
 
 	@RequestMapping(value = "/queries", produces = "application/json")
@@ -41,15 +40,12 @@ final class WorldDatabaseController {
 		List<Future<World>> wfs = new ArrayList<>(queryCount);
 		// it gets better with Java 8, promise!
 		for (int i = 0; i < queryCount; i++) {
-			wfs.add(
-				Common.EXECUTOR.submit(
-					new Callable<World>() {
-						@Override
-						public World call() throws Exception {
-							return worldRepository.findOne(
-								ThreadLocalRandom.current().nextInt(DB_ROWS) + 1);
-						}
-					}));
+			wfs.add(Common.EXECUTOR.submit(new Callable<World>() {
+				@Override
+				public World call() throws Exception {
+					return worldRepository.findOne(ThreadLocalRandom.current().nextInt(DB_ROWS) + 1);
+				}
+			}));
 		}
 
 		return waitFor(wfs);
@@ -57,23 +53,22 @@ final class WorldDatabaseController {
 
 	@RequestMapping(value = "/updates", produces = "application/json")
 	List<World> updateQueries(@RequestParam(value="queries", required=false, defaultValue="1") String rawQueryCount) {
-		Integer queryCount = boundQueryCount(rawQueryCount);
+		int queryCount = boundQueryCount(rawQueryCount);
 
 		List<Future<World>> wfs = new ArrayList<>(queryCount);
 
 		for (int i = 0; i < queryCount; i++) {
-			wfs.add(Common.EXECUTOR.submit(
-				new Callable<World>() {
-					@Override
-					@Transactional(propagation = Propagation.REQUIRES_NEW)
-					public World call() throws Exception {
-						Random random = ThreadLocalRandom.current();
-						World world = worldRepository.findOne(random.nextInt(DB_ROWS) + 1);
-						world.setRandomNumber(random.nextInt(DB_ROWS) + 1);
-						worldRepository.save(world);
-						return world;
-					}
-				}));
+			wfs.add(Common.EXECUTOR.submit(new Callable<World>() {
+				@Override
+				@Transactional(propagation = Propagation.REQUIRES_NEW)
+				public World call() throws Exception {
+					Random random = ThreadLocalRandom.current();
+					World world = worldRepository.findOne(random.nextInt(DB_ROWS) + 1);
+					world.setRandomNumber(random.nextInt(DB_ROWS) + 1);
+					worldRepository.save(world);
+					return world;
+				}
+			}));
 		}
 
 		return waitFor(wfs);
@@ -91,19 +86,17 @@ final class WorldDatabaseController {
 		return worlds;
 	}
 
-	private Integer boundQueryCount(final String rawString) {
-		Integer raw;
+	private int boundQueryCount(final String rawString) {
 		try {
-			raw = Integer.parseInt(rawString);
+			int raw = Integer.parseInt(rawString);
+			if (raw < 1) {
+				return 1;
+			} else if (raw > 500) {
+				return 500;
+			}
+			return raw;
 		} catch (NumberFormatException e) {
-			raw = null;
-		}
-		if (raw == null || raw < 1) {
 			return 1;
-		} else if (raw > 500) {
-			return 500;
 		}
-
-		return raw;
 	}
 }

+ 1 - 0
frameworks/Java/spring/src/main/resources/application.yml

@@ -22,4 +22,5 @@ spring:
     url: jdbc:h2:mem:framework_benchmark
   jpa:
     hibernate:
+      naming-strategy: org.hibernate.cfg.EJB3NamingStrategy
       ddl-auto: create-drop

+ 7 - 7
frameworks/Java/wildfly-ee7/pom.xml

@@ -12,8 +12,8 @@
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<version.compiler.plugin>3.1</version.compiler.plugin>
 		<version.war.plugin>2.4</version.war.plugin>
-		<version.wildfly>9.0.0.Beta2</version.wildfly>
-		<version.mysql.connector>5.1.34</version.mysql.connector>
+		<version.wildfly>9.0.1.Final</version.wildfly>
+		<version.mysql.connector>5.1.36</version.mysql.connector>
 		<version.javaee.api>7.0</version.javaee.api>
 		<version.jboss.spec.javaee.7.0>1.0.0.Final</version.jboss.spec.javaee.7.0>
 	</properties>
@@ -76,11 +76,11 @@
 			<scope>provided</scope>
 		</dependency>
 
-                <dependency>
-                        <groupId>io.undertow</groupId>
-                        <artifactId>undertow-servlet</artifactId>
-                        <scope>provided</scope>
-                </dependency>
+		<dependency>
+			<groupId>io.undertow</groupId>
+			<artifactId>undertow-servlet</artifactId>
+			<scope>provided</scope>
+		</dependency>
 
 		<dependency>
 			<groupId>org.jboss.spec.javax.ejb</groupId>

+ 1 - 1
frameworks/Java/wildfly-ee7/setup.sh

@@ -5,4 +5,4 @@ fw_depends java7 maven
 export JAVA_OPTS="-Xms2g -Xmx2g -XX:MaxPermSize=256m -XX:+UseG1GC -XX:MaxGCPauseMillis=25 -verbosegc -Xloggc:/tmp/wildfly_gc.log"
 
 mvn clean initialize package -Pbenchmark -Ddatabase.host=${DBHOST}
-target/wildfly-9.0.0.Beta2/bin/standalone.sh -b 0.0.0.0 &
+target/wildfly-9.0.1.Final/bin/standalone.sh -b 0.0.0.0 &

+ 3 - 2
frameworks/Python/cherrypy/app.py

@@ -1,10 +1,10 @@
+import cgi
 import os
 import sys
 from functools import partial
 from operator import attrgetter
 from random import randint
 import json
-import bleach
 
 import cherrypy
 from sqlalchemy.ext.declarative import declarative_base
@@ -59,6 +59,7 @@ class CherryPyBenchmark(object):
 
     @cherrypy.expose
     def plaintext(self):
+        cherrypy.response.headers["Content-Type"] = "text/plain"
         return "Hello, world!"
 
     @cherrypy.expose
@@ -111,7 +112,7 @@ class CherryPyBenchmark(object):
         fortunes.sort(key=attrgetter("message"))
         html = "<!DOCTYPE html><html><head><title>Fortunes</title></head><body><table><tr><th>id</th><th>message</th></tr>"
         for f in fortunes:
-            html += "<tr><td>" + str(f.id) + "</td><td>" + bleach.clean(f.message) + "</td></tr>"
+            html += "<tr><td>" + str(f.id) + "</td><td>" + cgi.escape(f.message) + "</td></tr>"
         html += "</table></body></html>"
         return html
 

+ 0 - 3
frameworks/Python/cherrypy/requirements.txt

@@ -1,6 +1,3 @@
 cherrypy==3.7.0
-
-bleach==1.4.1
-
 SQLAlchemy==1.0.4
 mysqlclient==1.3.6

+ 2 - 2
frameworks/Python/historical/webware/app/Context/fortune.py

@@ -1,5 +1,5 @@
+import cgi
 import json
-import bleach
 from random import randint
 from operator import attrgetter
 
@@ -16,7 +16,7 @@ class fortune(Page):
                 fortunes.append(AFortune(id=0, message="Additional fortune added at request time."))
                 fortunes.sort(key=attrgetter("message"))
                 for fortune in fortunes:
-                        message = bleach.clean(fortune.message)
+                        message = cgi.escape(fortune.message)
                         output += "<tr><td>%s</td><td>%s</td></tr>" % (fortune.id , message.encode("utf-8"))
                 output += "</table></body></html>"
                 self.response()._headers["Content-Length"] = len(output)

+ 0 - 1
frameworks/Python/historical/webware/requirements.txt

@@ -1,3 +1,2 @@
-bleach==1.4.1
 mysqlclient==1.3.6
 SQLAlchemy==1.0.4

+ 17 - 7
frameworks/Python/wheezyweb/app.py

@@ -1,11 +1,10 @@
+import cgi
 import os
 import sys
 from functools import partial
 from operator import attrgetter
 from random import randint
 
-import bleach
-
 from wheezy.http import HTTPResponse
 from wheezy.http import WSGIApplication
 from wheezy.routing import url
@@ -109,15 +108,16 @@ class UpdatesHandler(BaseHandler):
         db_session.commit()
         return self.json_response(worlds)
 
+
+template_engine = Engine(loader=FileLoader(["views"]), extensions=[CoreExtension()])
+template_engine.global_vars['escape'] = cgi.escape
+
 class FortuneHandler(BaseHandler):
     def get(self):
         fortunes = db_session.query(Fortune).all()
         fortunes.append(Fortune(id=0, message="Additional fortune added at request time."))
         fortunes.sort(key=attrgetter("message"))
-        engine = Engine(loader=FileLoader(["views"]), extensions=[CoreExtension()])
-        template = engine.get_template("fortune.html")
-        for f in fortunes:
-            f.message = bleach.clean(f.message)
+        template = template_engine.get_template("fortune.html")
         template_html = template.render({"fortunes": fortunes})		
 
         response = HTTPResponse()
@@ -130,6 +130,15 @@ def plaintext(request):
     response.write("Hello, world!")
     return response
 
+
+def sqlalchemy_close_middleware(request, following):
+    """Close db_session for each request"""
+    try:
+        return following(request)
+    finally:
+        db_session.remove()
+
+
 all_urls = [
     url("plaintext", plaintext, name="plaintext"),
     url("json", JsonHandler, name="json"),
@@ -144,7 +153,8 @@ options = {}
 app = WSGIApplication(
     middleware = [
         bootstrap_defaults(url_mapping=all_urls),
-        path_routing_middleware_factory
+        path_routing_middleware_factory,
+        lambda _: sqlalchemy_close_middleware,
     ],
     options = options
 )

+ 0 - 2
frameworks/Python/wheezyweb/requirements.txt

@@ -1,8 +1,6 @@
 wheezy.web==0.1.485
 wheezy.template==0.1.167
 
-bleach==1.4.1
-
 SQLAlchemy==1.0.4
 mysqlclient==1.3.6
 

+ 1 - 1
frameworks/Python/wheezyweb/views/fortune.html

@@ -13,7 +13,7 @@
 @for fortune in fortunes:
 <tr>
 <td>@str(fortune.id)</td>
-<td>@fortune.message</td>
+<td>@{fortune.message !! escape}</td>
 </tr>
 @end
 </table>

+ 7 - 4
frameworks/Scala/finch/build.sbt

@@ -1,16 +1,19 @@
 name := """techempower-benchmarks-finch"""
 
-version := "0.0.1-SNAPSHOT"
+version := "0.0.2"
 
-scalaVersion := "2.11.6"
+scalaVersion := "2.11.7"
 
 com.github.retronym.SbtOneJar.oneJarSettings
 
 mainClass in (Compile, run) := Some("WebServer")
 
 libraryDependencies ++= Seq(
-  "com.github.finagle" %% "finch-core" % "0.7.1",
-  "com.github.finagle" %% "finch-argonaut" % "0.7.1"
+  "com.github.finagle" %% "finch-core" % "0.8.0",
+  "com.github.finagle" %% "finch-circe" % "0.8.0",
+  "io.circe" %% "circe-core" % "0.1.1",
+  "io.circe" %% "circe-generic" % "0.1.1",
+  "io.circe" %% "circe-jawn" % "0.1.1"
 )
 
 resolvers += Resolver.sonatypeRepo("snapshots")

+ 19 - 15
frameworks/Scala/finch/src/main/scala/WebServer.scala

@@ -1,34 +1,38 @@
 import java.net.InetSocketAddress
 
-import argonaut._, Argonaut._
-
 import io.finch._
-import io.finch.{Endpoint => _, _}
-
 import io.finch.route._
-import io.finch.route.Endpoint
 import io.finch.response._
 
 import com.twitter.finagle.Service
 import com.twitter.finagle.Httpx
+import com.twitter.finagle.httpx.{Response, Request}
 
 import com.twitter.util.Await
 
+import io.circe._
+import io.circe.generic.auto._
+import io.circe.jawn._
+import io.circe.syntax._
+import io.finch.response.EncodeResponse
+import io.circe.{Decoder, Encoder, Json}
+
 object WebServer extends App {
 
-  val json: Endpoint[HttpRequest, HttpResponse] = {
-    import io.finch.argonaut._
-    Get / "json" /> Ok(Json("message" -> jString("Hello, World!"))).toFuture
+  val json = get("json") {
+    import io.finch.circe._
+
+    case class Message(message: String)
+    Ok(Message("Hello, World!").asJson)
   }
 
-  val plaintext: Endpoint[HttpRequest, HttpResponse] =
-    Get / "plaintext" /> Ok("Hello, World!").toFuture
+  val plaintext = get("plaintext") {
+    "Hello, World!"
+  }
 
-  val api: Service[HttpRequest, HttpResponse] = plaintext | json
+  val api: Service[Request, Response] = (json :+: plaintext).toService
 
   Await.ready(
-    Httpx.serve(
-      "0.0.0.0:9000", api
-    )
+    Httpx.serve(":9000", api)
   )
-}
+}

+ 1 - 1
toolset/setup/linux/languages/elixir.sh

@@ -8,7 +8,7 @@ RETCODE=$(fw_exists ${IROOT}/elixir.installed)
   return 0; }
 
 ELIXIR_HOME=$IROOT/elixir
-VERSION="1.0.4-1"
+VERSION="1.1.0-1"
 RELEASE="trusty"
 ARCH="amd64"
 

+ 1 - 1
toolset/setup/linux/languages/erlang.sh

@@ -9,7 +9,7 @@ VERSION="17.4-2"
 RELEASE="trusty"
 ARCH="amd64"
 
-fw_get -O http://packages.erlang-solutions.com/site/esl/esl-erlang/FLAVOUR_1_esl/esl-erlang_${VERSION}~ubuntu~${RELEASE}_${ARCH}.deb
+fw_get -O http://packages.erlang-solutions.com/site/esl/esl-erlang/FLAVOUR_2_esl/esl-erlang_${VERSION}~ubuntu~${RELEASE}_${ARCH}.deb
 dpkg -x esl-erlang_${VERSION}~ubuntu~${RELEASE}_${ARCH}.deb $IROOT/erlang
 $IROOT/erlang/usr/lib/erlang/Install -minimal $IROOT/erlang/usr/lib/erlang