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

Commit 120fa3f

Browse files
author
Olivier Bonnaure
committed
feat(rust/soli): add fortune endpoint and update benchmark configuration
- Introduced a new fortune endpoint that queries fortunes from SoliDB, adds a runtime fortune, sorts, and renders HTML. - Updated benchmark_config.json to include a new fortune URL, changed classification to "Fullstack", and updated database and ORM settings. - Removed the obsolete soli.dockerfile as part of the cleanup.
1 parent af3c0d8 commit 120fa3f

12 files changed

Lines changed: 344 additions & 28 deletions

File tree

frameworks/Rust/soli/app/controllers/bench_controller.sl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ fn plaintext(req: Any) -> Any {
1010
fn json(req: Any) -> Any {
1111
return render_json({ "message": "Hello, World!" });
1212
}
13+
14+
// Fortune endpoint - queries fortunes from SoliDB, adds runtime fortune, sorts, renders HTML
15+
fn fortunes(req: Any) -> Any {
16+
let fortunes = Fortune.all();
17+
fortunes.push({ "id": 0, "message": "Additional fortune added at request time." });
18+
let sorted = fortunes.sort_by("message");
19+
return render("fortunes/index", { "fortunes": sorted });
20+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Fortune model for TechEmpower benchmark
2+
class Fortune extends Model {
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head><title>Fortunes</title></head>
4+
<body>
5+
<table>
6+
<tr><th>id</th><th>message</th></tr>
7+
<% for fortune in fortunes %>
8+
<tr><td><%= fortune["id"] %></td><td><%= fortune["message"] %></td></tr>
9+
<% end %>
10+
</table>
11+
</body>
12+
</html>

frameworks/Rust/soli/benchmark_config.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55
"default": {
66
"plaintext_url": "/plaintext",
77
"json_url": "/json",
8+
"fortune_url": "/fortunes",
89
"port": 3000,
910
"approach": "Realistic",
10-
"classification": "Platform",
11-
"database": "None",
11+
"classification": "Fullstack",
1212
"framework": "soli",
1313
"language": "Rust",
14-
"orm": "Raw",
14+
"database": "solidb",
15+
"orm": "Full",
1516
"platform": "Rust",
1617
"webserver": "soli",
1718
"os": "Linux",
1819
"database_os": "Linux",
1920
"display_name": "Soli",
2021
"notes": "Soli MVC Framework",
21-
"versus": "hyper"
22+
"versus": "hyper",
23+
"dockerfile": "soli-solidb.dockerfile"
2224
}
2325
}]
2426
}

frameworks/Rust/soli/config/routes.sl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ get("/plaintext", "bench#plaintext");
55

66
// JSON endpoint
77
get("/json", "bench#json");
8+
9+
// Fortune endpoint
10+
get("/fortunes", "bench#fortunes");

frameworks/Rust/soli/entrypoint.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
set -e
3+
4+
BASE="http://tfb-database:6745"
5+
6+
# Wait for SoliDB to be ready
7+
echo "Waiting for SoliDB to be ready..."
8+
echo "BASE: $BASE"
9+
10+
READY=false
11+
for i in $(seq 1 60); do
12+
if curl -sf "$BASE/_api/health" > /dev/null 2>&1; then
13+
READY=true
14+
break
15+
fi
16+
echo "Attempt $i: SoliDB not ready, retrying..."
17+
sleep 1
18+
done
19+
20+
if [ "$READY" != "true" ]; then
21+
echo "ERROR: SoliDB did not become ready after 60 seconds"
22+
exit 1
23+
fi
24+
25+
echo "SoliDB is ready"
26+
27+
# Authenticate and get JWT token
28+
TOKEN=$(curl -sf -X POST "$BASE/auth/login" \
29+
-H "Content-Type: application/json" \
30+
-d '{"username": "admin", "password": "benchmarkdbpass"}' \
31+
| sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
32+
33+
# Create an API key
34+
API_KEY=$(curl -sf -X POST "$BASE/_api/auth/api-keys" \
35+
-H "Content-Type: application/json" \
36+
-H "Authorization: Bearer $TOKEN" \
37+
-d '{"name": "soli-benchmark"}' \
38+
| sed -n 's/.*"key":"\([^"]*\)".*/\1/p')
39+
40+
echo "API key created: ${API_KEY:0:8}..."
41+
42+
# Write .env file for the soli framework
43+
cat > /app/.env <<EOF
44+
SOLIDB_HOST=$BASE
45+
SOLIDB_DATABASE=hello_world
46+
SOLIDB_API_KEY=$API_KEY
47+
EOF
48+
49+
echo "Starting Soli server..."
50+
exec soli serve /app --port 3000 --workers $(($(nproc)*5/4))
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM debian:trixie-slim
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
curl \
5+
ca-certificates \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
WORKDIR /app
9+
10+
# Install soli via install script
11+
RUN curl -sSL https://raw.githubusercontent.com/solisoft/soli_lang/main/install.sh | sh
12+
13+
ENV PATH="/root/.local/bin:$PATH"
14+
15+
# Copy benchmark application files
16+
COPY app/ /app/app/
17+
COPY config/ /app/config/
18+
19+
# Copy entrypoint script
20+
COPY entrypoint.sh /app/entrypoint.sh
21+
RUN chmod +x /app/entrypoint.sh
22+
23+
EXPOSE 3000
24+
25+
CMD ["/app/entrypoint.sh"]

frameworks/Rust/soli/soli.dockerfile

Lines changed: 0 additions & 24 deletions
This file was deleted.

toolset/databases/solidb/__init__.py

Whitespace-only changes.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
set -e
3+
4+
solidb &
5+
SOLIDB_PID=$!
6+
7+
BASE="http://localhost:6745"
8+
9+
# Wait for SoliDB to be ready
10+
for i in $(seq 1 30); do
11+
if curl -sf "$BASE/_api/health" > /dev/null 2>&1; then
12+
break
13+
fi
14+
sleep 1
15+
done
16+
17+
# Authenticate and get JWT token
18+
TOKEN=$(curl -sf -X POST "$BASE/auth/login" \
19+
-H "Content-Type: application/json" \
20+
-d '{"username": "admin", "password": "benchmarkdbpass"}' \
21+
| sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
22+
23+
AUTH="Authorization: Bearer $TOKEN"
24+
25+
# Create database
26+
curl -sf -X POST "$BASE/_api/database" \
27+
-H "Content-Type: application/json" \
28+
-H "$AUTH" \
29+
-d '{"name": "hello_world"}' || true
30+
31+
DB="$BASE/_api/database/hello_world"
32+
33+
# Create collections before inserting documents
34+
curl -sf -X POST "$DB/collection" \
35+
-H "Content-Type: application/json" \
36+
-H "$AUTH" \
37+
-d '{"name": "fortunes"}' || true
38+
39+
curl -sf -X POST "$DB/collection" \
40+
-H "Content-Type: application/json" \
41+
-H "$AUTH" \
42+
-d '{"name": "worlds"}' || true
43+
44+
# Seeding errors should not kill the database container
45+
set +e
46+
47+
# Seed fortune collection via batch insert
48+
curl -sf -X POST "$DB/document/fortunes/_batch" \
49+
-H "Content-Type: application/json" \
50+
-H "$AUTH" \
51+
-H "X-Shard-Direct: true" \
52+
-d '[
53+
{"id": 1, "message": "fortune: No such file or directory"},
54+
{"id": 2, "message": "A computer scientist is someone who fixes things that aren'\''t broken."},
55+
{"id": 3, "message": "After enough decimal places, nobody gives a damn."},
56+
{"id": 4, "message": "A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1"},
57+
{"id": 5, "message": "A computer program does what you tell it to do, not what you want it to do."},
58+
{"id": 6, "message": "Emacs is a nice operating system, but I prefer UNIX. \u2014 Tom Christaensen"},
59+
{"id": 7, "message": "Any program that runs right is obsolete."},
60+
{"id": 8, "message": "A list is only as strong as its weakest link. \u2014 Donald Knuth"},
61+
{"id": 9, "message": "Feature: A bug with seniority."},
62+
{"id": 10, "message": "Computers make very fast, very accurate mistakes."},
63+
{"id": 11, "message": "<script>alert(\"This should not be displayed in a browser alert box.\");<\/script>"},
64+
{"id": 12, "message": "\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u30d9\u30f3\u30c1\u30de\u30fc\u30af"}
65+
]'
66+
echo "Fortunes seeded: exit code $?"
67+
68+
# Seed world collection via batch inserts (1000 docs per batch)
69+
for batch in $(seq 0 9); do
70+
start=$((batch * 1000 + 1))
71+
end=$((batch * 1000 + 1000))
72+
docs="["
73+
for i in $(seq $start $end); do
74+
rnd=$(( (RANDOM % 10000) + 1 ))
75+
if [ $i -gt $start ]; then docs="$docs,"; fi
76+
docs="$docs{\"id\":$i,\"randomNumber\":$rnd}"
77+
done
78+
docs="$docs]"
79+
curl -sf -X POST "$DB/document/worlds/_batch" \
80+
-H "Content-Type: application/json" \
81+
-H "$AUTH" \
82+
-H "X-Shard-Direct: true" \
83+
-d "$docs"
84+
echo "World batch $batch seeded: exit code $?"
85+
done
86+
87+
echo "SoliDB seeding complete"
88+
89+
wait $SOLIDB_PID

0 commit comments

Comments
 (0)