فهرست منبع

Add Clojure + reitit suite. (#3052)

Tommi Reiman 7 سال پیش
والد
کامیت
546ffe8b6c

+ 1 - 0
.travis.yml

@@ -41,6 +41,7 @@ env:
     - "TESTDIR=Clojure/macchiato"
     - "TESTDIR=Clojure/pedestal"
     - "TESTDIR=Clojure/aleph"
+    - "TESTDIR=Clojure/reitit"
     - "TESTDIR=Crystal/amber"
     - "TESTDIR=Crystal/crystal"
     - "TESTDIR=Crystal/kemal"

+ 22 - 0
frameworks/Clojure/reitit/README.md

@@ -0,0 +1,22 @@
+# Reitit Benchmarking Test
+
+This is the [Reitit](https://github.com/metosin/reitit) portion of a [benchmarking test suite](../) comparing a variety of web development platforms.
+
+### JSON Encoding Test
+
+* [JSON test source](hello/src/hello/handler.clj)
+
+## Infrastructure Software Versions
+
+The dependencies are documented in [project.clj](hello/project.clj),
+but the main ones are:
+
+* [Immutant 2.1.9](http://immutant.org/)
+* [Clojure 1.9.0-RC1](http://clojure.org/)
+* [metosin/jsonista "0.1.0-20171106.055332-4"](https://github.com/metosin/jsonista)
+* [metosin/reitit "0.1.0-20171101.170818-9"](https://github.com/metosin/reitit)
+
+## Test URLs
+### JSON Encoding Test
+
+http://localhost:8080/json

+ 24 - 0
frameworks/Clojure/reitit/benchmark_config.json

@@ -0,0 +1,24 @@
+{
+  "framework": "reitit",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "json_url": "/json",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "None",
+      "framework": "reitit",
+      "language": "Clojure",
+      "flavor": "None",
+      "orm": "Raw",
+      "platform": "Netty",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "reitit",
+      "notes": "",
+      "versus": "netty"
+    }
+  }]
+}

+ 11 - 0
frameworks/Clojure/reitit/hello/.gitignore

@@ -0,0 +1,11 @@
+/target
+/lib
+/classes
+/checkouts
+pom.xml
+*.jar
+*.class
+.lein-deps-sum
+.lein-failures
+.lein-plugins
+.lein-env

+ 9 - 0
frameworks/Clojure/reitit/hello/project.clj

@@ -0,0 +1,9 @@
+(defproject hello "reitit"
+  :description "Immutant, Reitit, Jsonista"
+  :dependencies [[org.clojure/clojure "1.9.0-RC1"]
+                 [org.clojure/tools.cli "0.3.5"]
+                 [org.immutant/web "2.1.9"]
+                 [metosin/jsonista "0.1.0-20171106.055332-4"]
+                 [metosin/reitit "0.1.0-20171101.170818-9"]]
+  :main hello.handler
+  :aot :all)

+ 33 - 0
frameworks/Clojure/reitit/hello/src/hello/handler.clj

@@ -0,0 +1,33 @@
+(ns hello.handler
+  (:require [clojure.tools.cli :as cli]
+            [immutant.web :as web]
+            [reitit.ring :as ring]
+            [jsonista.core :as j])
+  (:gen-class))
+
+(defn json-handler [_]
+  {:status 200
+   :headers {"Content-Type" "application/json"}
+   :body (j/write-value-as-string {:message "Hello, World!"})})
+
+(def app
+  (some-fn
+    (ring/ring-handler
+      (ring/router
+        [["/json" json-handler]]))
+    (constantly {:status 404})))
+
+(defn -main [& args]
+
+  (let [[{:keys [help port]} _ banner]
+        (cli/cli args
+                 ["-p" "--port" "Server port"
+                  :default 8080
+                  :parse-fn #(Integer/parseInt %)]
+                 ["-h" "--[no-]help"])]
+
+    (when help
+      (println banner)
+      (System/exit 0))
+
+    (web/run app {:host "localhost" :port port})))

+ 7 - 0
frameworks/Clojure/reitit/hello/src/log4j.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+  <logger name="com.mchange">
+    <level value="WARN"/>
+  </logger>
+</log4j:configuration>

+ 8 - 0
frameworks/Clojure/reitit/setup.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+fw_depends java leiningen
+
+cd hello
+lein clean
+lein uberjar
+java -server -Xmx2g -XX:+UseG1GC -XX:MaxGCPauseMillis=10 -jar target/*-standalone.jar &

+ 2 - 0
frameworks/Clojure/reitit/source_code

@@ -0,0 +1,2 @@
+./reitit/hello/src/hello/handler.clj
+./reitit/hello/project.clj