diff --git a/frameworks/Clojure/reitit/benchmark_config.json b/frameworks/Clojure/reitit/benchmark_config.json
index 76bb97d58ea..071513ab84b 100755
--- a/frameworks/Clojure/reitit/benchmark_config.json
+++ b/frameworks/Clojure/reitit/benchmark_config.json
@@ -3,10 +3,12 @@
"tests": [{
"default": {
"json_url": "/json",
+ "plaintext_url": "/plaintext",
+ "db_url": "/db",
"port": 8080,
"approach": "Realistic",
"classification": "Micro",
- "database": "None",
+ "database": "Postgres",
"framework": "reitit",
"language": "Clojure",
"flavor": "None",
diff --git a/frameworks/Clojure/reitit/project.clj b/frameworks/Clojure/reitit/project.clj
index d52a390cd36..9b6b99edfcd 100644
--- a/frameworks/Clojure/reitit/project.clj
+++ b/frameworks/Clojure/reitit/project.clj
@@ -1,9 +1,12 @@
(defproject hello "reitit"
- :description "Immutant, Reitit, Jsonista"
+ :description "Immutant-nio, Reitit, Jsonista & Porsas"
:dependencies [[org.clojure/clojure "1.10.0"]
[ikitommi/immutant-web "3.0.0-alpha1"]
[metosin/jsonista "0.2.2"]
- [metosin/reitit "0.2.12"]]
+ [hikari-cp "2.7.1"]
+ [org.postgresql/postgresql "42.2.5"]
+ [metosin/porsas "0.0.1-alpha4"]
+ [metosin/reitit "0.3.1"]]
:jvm-opts ^:replace ["-Dclojure.compiler.direct-linking=true"]
:main hello.handler
:aot :all)
diff --git a/frameworks/Clojure/reitit/src/hello/handler.clj b/frameworks/Clojure/reitit/src/hello/handler.clj
index 7137ace460e..3eb2b9221ee 100644
--- a/frameworks/Clojure/reitit/src/hello/handler.clj
+++ b/frameworks/Clojure/reitit/src/hello/handler.clj
@@ -1,24 +1,68 @@
(ns hello.handler
(:require [immutant.web :as web]
+ [hikari-cp.core :as hikari]
[reitit.ring :as ring]
+ [porsas.core :as p]
[jsonista.core :as j])
- (:gen-class))
+ (:gen-class)
+ (:import (java.util.concurrent ThreadLocalRandom)
+ (io.undertow.server HttpServerExchange)))
+
+(defn blocking [handler]
+ (fn [req]
+ (.startBlocking ^HttpServerExchange (:server-exchange req))
+ (handler req)))
+
+(defn random []
+ (unchecked-inc (.nextInt (ThreadLocalRandom/current) 10000)))
+
+(def query-one (:query-one (p/compile {:row (p/rs->compiled-record)})))
+
+(defn random-world [ds]
+ (with-open [con (p/get-connection ds)]
+ (query-one con ["SELECT id, randomnumber from WORLD where id=?" (random)])))
+
+(defn plain-text-handler [_]
+ {:status 200
+ :headers {"content-type" "text/plain; charset=utf-8"}
+ :body (.getBytes "Hello, World!")})
(defn json-handler [_]
{:status 200
:headers {"Content-Type" "application/json"}
:body (j/write-value-as-bytes {:message "Hello, World!"})})
-(def app
- (ring/ring-handler
- (ring/router ["/json" json-handler])
- (ring/create-default-handler)
- {:inject-match? false, :inject-router? false}))
+(defn db-handler [ds]
+ (fn [_]
+ {:status 200
+ :headers {"Content-Type" "application/json"}
+ :body (j/write-value-as-bytes (random-world ds))}))
(defn -main [& _]
- (web/run
- app
- {:port 8080
- :host "0.0.0.0"
- :dispatch? false
- :server {:always-set-keep-alive false}}))
\ No newline at end of file
+ (let [ds (hikari/make-datasource
+ {:read-only true
+ :maximum-pool-size 64
+ :pool-name "db-pool"
+ :adapter "postgresql"
+ :username "benchmarkdbuser"
+ :password "benchmarkdbpass"
+ :database-name "hello_world"
+ :server-name "tfb-database"
+ :port-number 5432
+ :register-mbeans false})]
+ (web/run
+ (ring/ring-handler
+ (ring/router
+ [["/plaintext" plain-text-handler]
+ ["/json" json-handler]
+ ["/db" (blocking (db-handler ds))]])
+ (ring/create-default-handler)
+ {:inject-match? false, :inject-router? false})
+ {:port 8080
+ :host "0.0.0.0"
+ :dispatch? false
+ :worker-threads 64
+ :server {:always-set-keep-alive false}})))
+
+(comment
+ (-main))
diff --git a/frameworks/Clojure/reitit/src/log4j.xml b/frameworks/Clojure/reitit/src/log4j.xml
deleted file mode 100644
index d6fb5200955..00000000000
--- a/frameworks/Clojure/reitit/src/log4j.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/frameworks/Clojure/reitit/src/logback.xml b/frameworks/Clojure/reitit/src/logback.xml
new file mode 100644
index 00000000000..7cfd3047c38
--- /dev/null
+++ b/frameworks/Clojure/reitit/src/logback.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file