Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Commit 5a1d936

Browse files
rurorujj
andauthored
Update dependencies in ring-http-exchange (#10765)
Also updated executor and hikaricp connection settings Co-authored-by: jj <keistaslogairkosulys@gmail.com>
1 parent 5497582 commit 5a1d936

5 files changed

Lines changed: 34 additions & 39 deletions

File tree

frameworks/Clojure/ring-http-exchange/project.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
:dependencies [[org.clojure/clojure "1.12.3"]
88
[org.clojure/tools.logging "1.3.0"]
9-
[org.clojars.jj/ring-http-exchange "1.2.16"]
9+
[org.clojars.jj/ring-http-exchange "1.4.1"]
1010
[seancorfield/next.jdbc "1.2.659"]
11-
[org.clojars.jj/majavat "1.18.0"]
11+
[org.clojars.jj/majavat "1.19.0"]
1212
[hikari-cp "3.3.0"]
13-
[org.clojars.jj/boa-sql "1.0.1"]
13+
[org.clojars.jj/boa-sql "1.0.3"]
1414
[org.postgresql/postgresql "42.7.8"]
1515
[metosin/jsonista "0.3.13"]
1616
]

frameworks/Clojure/ring-http-exchange/src/ring_http_exchange/benchmark.clj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
(def db-spec {:idle-timeout 15000
1313
:max-lifetime 60000
14-
:minimum-idle 0
15-
:maximum-pool-size 1024
14+
:minimum-idle (* 3 (.availableProcessors (Runtime/getRuntime)))
15+
:maximum-pool-size (* 3 (.availableProcessors (Runtime/getRuntime)))
1616
:jdbcUrl "jdbc:postgresql://tfb-database/hello_world?user=benchmarkdbuser&password=benchmarkdbpass&tlsnowait=true"})
1717

1818
(defn -main
@@ -29,6 +29,7 @@
2929
(if use-inputstream?
3030
(input-stream-handler/get-handler datasource)
3131
(string-handler/get-handler datasource))
32-
{:port 8080
33-
:host "0.0.0.0"
34-
:executor (Executors/newCachedThreadPool)})))
32+
{:port 8080
33+
:host "0.0.0.0"
34+
:lazy-request-map? true
35+
:executor (Executors/newFixedThreadPool (* 3 (.availableProcessors (Runtime/getRuntime))))})))

frameworks/Clojure/ring-http-exchange/src/ring_http_exchange/input_stream_handler.clj

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,22 @@
22
(:require
33
[jj.majavat :as majavat]
44
[jj.majavat.renderer :refer [->InputStreamRenderer]]
5-
[jj.sql.boa :as boa])
5+
[ring-http-exchange.model :as model])
66
(:import (java.io ByteArrayInputStream)))
77

88
(defrecord Response [body status headers])
99

10-
(def query-fortunes (boa/build-query (boa/->NextJdbcAdapter) "fortune.sql"))
11-
1210
(def ^:private hello-world-bytes (.getBytes "Hello, World!"))
13-
1411
(def ^:private ^:const fortune-headers {"Server" "ring-http-exchange"
1512
"Content-Type" "text/html; charset=UTF-8"})
1613

1714
(def ^:private render-fortune (majavat/build-html-renderer "fortune.html"
1815
{:renderer (->InputStreamRenderer)}))
1916

20-
(defn- get-body [datasource]
21-
(let [context (as-> (query-fortunes datasource) fortunes
22-
(conj fortunes {:id 0
23-
:message "Additional fortune added at request time."})
24-
(sort-by :message fortunes))]
25-
(render-fortune {:messages context})))
26-
2717
(defn get-handler [data-source]
2818
(fn [req]
2919
(case (req :uri)
30-
"/fortunes" (Response. (get-body data-source) 200 fortune-headers)
20+
"/fortunes" (Response. (render-fortune (model/fortunes-body data-source)) 200 fortune-headers)
3121
(Response. (ByteArrayInputStream. hello-world-bytes) 200 {"Server" "ring-http-exchange"
3222
"Content-Type" "text/plain"}))))
3323

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(ns ring-http-exchange.model
2+
(:require [jj.sql.boa :as boa]
3+
[jj.sql.boa.query.next-jdbc :as next-jdbc-adapter]
4+
[jsonista.core :as json]))
5+
6+
(def ^:const hello-world "Hello, World!")
7+
(def query-fortunes (boa/build-query (next-jdbc-adapter/->NextJdbcAdapter) "fortune.sql"))
8+
9+
(defn json-body []
10+
(json/write-value-as-string {:message hello-world}))
11+
12+
(defn fortunes-body [data-source]
13+
{:messages (as-> (query-fortunes data-source) fortunes
14+
(conj fortunes {:id 0
15+
:message "Additional fortune added at request time."})
16+
(sort-by :message fortunes))})
17+
Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
(ns ring-http-exchange.string-handler
22
(:require
33
[jj.majavat :as majavat]
4-
[jj.sql.boa :as boa]
5-
[jsonista.core :as json]))
4+
[ring-http-exchange.model :as model]))
65

76
(defrecord Response [body status headers])
8-
9-
(def query-fortunes (boa/build-query (boa/->NextJdbcAdapter) "fortune.sql"))
10-
11-
(def ^:private ^:const hello-world "Hello, World!")
12-
137
(def ^:private ^:const fortune-headers {"Server" "ring-http-exchange"
148
"Content-Type" "text/html; charset=UTF-8"})
159
(def ^:private ^:const json-headers {"Server" "ring-http-exchange"
@@ -19,19 +13,12 @@
1913

2014
(def ^:private render-fortune (majavat/build-html-renderer "fortune.html"))
2115

22-
(defn- get-body [datasource]
23-
(let [context (as-> (query-fortunes datasource) fortunes
24-
(conj fortunes {:id 0
25-
:message "Additional fortune added at request time."})
26-
(sort-by :message fortunes))]
27-
(render-fortune {:messages context})))
28-
2916
(defn get-handler [data-source]
3017
(fn [req]
3118
(case (req :uri)
32-
"/plaintext" (Response. hello-world 200 plain-text-headers)
33-
"/json" (Response. (json/write-value-as-string {:message hello-world}) 200 json-headers)
34-
"/fortunes" (Response. (get-body data-source) 200 fortune-headers)
35-
(Response. hello-world 200 {"Server" "ring-http-exchange"
36-
"Content-Type" "text/plain"}))))
19+
"/plaintext" (Response. model/hello-world 200 plain-text-headers)
20+
"/json" (Response. (model/json-body) 200 json-headers)
21+
"/fortunes" (Response. (render-fortune (model/fortunes-body data-source)) 200 fortune-headers)
22+
(Response. model/hello-world 200 {"Server" "ring-http-exchange"
23+
"Content-Type" "text/plain"}))))
3724

0 commit comments

Comments
 (0)