Skip to content

Commit 5f109a0

Browse files
authored
Add ring-http-exchange (#9948)
1 parent cb37ac5 commit 5f109a0

File tree

6 files changed

+259
-0
lines changed

6 files changed

+259
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# ring-http-exchange Benchmarking Test
2+
3+
## Test Type Implementation Source Code
4+
* [JSON](src/ring_http_exchange/benchmark.clj)
5+
* [PLAINTEXT](src/ring_http_exchange/benchmark.clj)
6+
7+
## Important Libraries
8+
The tests were run with:
9+
* [ring-http-exchange](https://github.com/ruroru/ring-http-exchange)
10+
* [jsonista](https://github.com/metosin/jsonista)
11+
12+
## Test URLs
13+
### JSON
14+
http://localhost:8080/json
15+
16+
### PLAINTEXT
17+
http://localhost:8080/plaintext
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"framework": "ring-http-exchange",
3+
"tests": [
4+
{
5+
"default": {
6+
"json_url": "/json",
7+
"plaintext_url": "/plaintext",
8+
"port": 8080,
9+
"approach": "Realistic",
10+
"classification": "Platform",
11+
"database": "None",
12+
"framework": "None",
13+
"language": "Clojure",
14+
"flavor": "None",
15+
"orm": "None",
16+
"platform": "None",
17+
"webserver": "None",
18+
"os": "Linux",
19+
"database_os": "Linux",
20+
"display_name": "ring-http-exchange",
21+
"notes": "",
22+
"versus": "httpserver"
23+
}
24+
},
25+
{
26+
"robaho": {
27+
"json_url": "/json",
28+
"plaintext_url": "/plaintext",
29+
"port": 8080,
30+
"approach": "Realistic",
31+
"classification": "Platform",
32+
"database": "None",
33+
"framework": "None",
34+
"language": "Clojure",
35+
"flavor": "None",
36+
"orm": "None",
37+
"platform": "None",
38+
"webserver": "None",
39+
"os": "Linux",
40+
"database_os": "Linux",
41+
"display_name": "ring-http-exchange-robaho",
42+
"notes": "",
43+
"versus": "ring-http-exchange"
44+
}
45+
}
46+
]
47+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>ring-http-server</groupId>
6+
<artifactId>ring-http-server</artifactId>
7+
<packaging>jar</packaging>
8+
<version>1.0.0</version>
9+
<name>ring-http-server</name>
10+
<licenses>
11+
<license>
12+
<name>EPL-2.0</name>
13+
<url>https://www.eclipse.org/legal/epl-2.0/</url>
14+
</license>
15+
</licenses>
16+
<build>
17+
<sourceDirectory>java</sourceDirectory>
18+
<testSourceDirectory>java-test</testSourceDirectory>
19+
<resources>
20+
<resource>
21+
<directory>resources</directory>
22+
</resource>
23+
</resources>
24+
<testResources>
25+
<testResource>
26+
<directory>resources</directory>
27+
</testResource>
28+
</testResources>
29+
<directory>target</directory>
30+
<outputDirectory>target\classes</outputDirectory>
31+
<plugins>
32+
<plugin>
33+
<groupId>com.theoryinpractise</groupId>
34+
<artifactId>clojure-maven-plugin</artifactId>
35+
<version>1.8.3</version>
36+
<extensions>true</extensions>
37+
<executions>
38+
<execution>
39+
<id>compile-clojure</id>
40+
<phase>compile</phase>
41+
<goals>
42+
<goal>compile</goal>
43+
</goals>
44+
</execution>
45+
<execution>
46+
<id>test-clojure</id>
47+
<phase>test</phase>
48+
<goals>
49+
<goal>test</goal>
50+
</goals>
51+
</execution>
52+
</executions>
53+
<configuration>
54+
<sourceDirectories>
55+
<sourceDirectory>src/</sourceDirectory>
56+
</sourceDirectories>
57+
</configuration>
58+
</plugin>
59+
<plugin>
60+
<artifactId>maven-assembly-plugin</artifactId>
61+
<configuration>
62+
<archive>
63+
<manifest>
64+
<mainClass>ring_http_exchange.benchmark</mainClass>
65+
</manifest>
66+
</archive>
67+
<descriptorRefs>
68+
<descriptorRef>jar-with-dependencies</descriptorRef>
69+
</descriptorRefs>
70+
</configuration>
71+
<executions>
72+
<execution>
73+
<id>make-assembly</id>
74+
<phase>package</phase>
75+
<goals>
76+
<goal>single</goal>
77+
</goals>
78+
</execution>
79+
</executions>
80+
</plugin>
81+
</plugins>
82+
</build>
83+
<repositories>
84+
<repository>
85+
<id>central</id>
86+
<url>https://repo1.maven.org/maven2/</url>
87+
<snapshots>
88+
<enabled>false</enabled>
89+
</snapshots>
90+
<releases>
91+
<enabled>true</enabled>
92+
</releases>
93+
</repository>
94+
<repository>
95+
<id>clojars</id>
96+
<url>https://repo.clojars.org/</url>
97+
<snapshots>
98+
<enabled>true</enabled>
99+
</snapshots>
100+
<releases>
101+
<enabled>true</enabled>
102+
</releases>
103+
</repository>
104+
</repositories>
105+
<dependencyManagement>
106+
<dependencies/>
107+
</dependencyManagement>
108+
<dependencies>
109+
<dependency>
110+
<groupId>org.clojure</groupId>
111+
<artifactId>clojure</artifactId>
112+
<version>1.11.1</version>
113+
</dependency>
114+
<dependency>
115+
<groupId>org.clojars.jj</groupId>
116+
<artifactId>ring-http-exchange</artifactId>
117+
<version>1.1.0</version>
118+
</dependency>
119+
<dependency>
120+
<groupId>metosin</groupId>
121+
<artifactId>jsonista</artifactId>
122+
<version>0.3.13</version>
123+
</dependency>
124+
</dependencies>
125+
<profiles>
126+
<profile>
127+
<id>robaho</id>
128+
<activation>
129+
<activeByDefault>false</activeByDefault>
130+
</activation>
131+
<dependencies>
132+
<dependency>
133+
<groupId>io.github.robaho</groupId>
134+
<artifactId>httpserver</artifactId>
135+
<version>1.0.23</version>
136+
</dependency>
137+
</dependencies>
138+
</profile>
139+
</profiles>
140+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM maven:3-eclipse-temurin-24-alpine as maven
2+
WORKDIR /ring-http-exchange
3+
COPY pom.xml pom.xml
4+
COPY src src
5+
RUN mvn clean clojure:compile -P robaho package
6+
7+
FROM openjdk:25-jdk-slim
8+
WORKDIR /ring-http-exchange
9+
COPY --from=maven /ring-http-exchange/target/ring-http-server-1.0.0-jar-with-dependencies.jar app.jar
10+
11+
EXPOSE 8080
12+
13+
CMD ["java", "-server", "-XX:+UseParallelGC", "-jar", "app.jar"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM maven:3-eclipse-temurin-24-alpine as maven
2+
WORKDIR /ring-http-exchange
3+
COPY pom.xml pom.xml
4+
COPY src src
5+
RUN mvn clean clojure:compile package
6+
7+
FROM openjdk:25-jdk-slim
8+
WORKDIR /ring-http-exchange
9+
COPY --from=maven /ring-http-exchange/target/ring-http-server-1.0.0-jar-with-dependencies.jar app.jar
10+
11+
EXPOSE 8080
12+
13+
CMD ["java", "-server", "-XX:+UseParallelGC", "-jar", "app.jar"]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
(ns ring-http-exchange.benchmark
2+
(:gen-class)
3+
(:require [jsonista.core :as json]
4+
[ring-http-exchange.core :as server])
5+
(:import
6+
(java.util.concurrent Executors)))
7+
8+
(def ^:private ^:const json-headers {"Server" "ring-http-exchange"
9+
"Content-Type" "application/json"})
10+
(def ^:private ^:const plaintext-response
11+
{:status 200
12+
:headers {
13+
"Server" "ring-http-exchange"
14+
"Content-Type" "text/plain"}
15+
:body "Hello, World!"})
16+
17+
(defn -main
18+
[& args]
19+
(println "Starting server on port 8080")
20+
(server/run-http-server
21+
(fn [req]
22+
(case (req :uri)
23+
"/json" {:status 200
24+
:headers json-headers
25+
:body (json/write-value-as-bytes {:message "Hello, World!"})}
26+
plaintext-response))
27+
{:port 8080
28+
:host "0.0.0.0"
29+
:executor (Executors/newVirtualThreadPerTaskExecutor)}))

0 commit comments

Comments
 (0)