Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions frameworks/Rust/soli/app/controllers/bench_controller.sl
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ fn plaintext(req: Any) -> Any {
fn json(req: Any) -> Any {
return render_json({ "message": "Hello, World!" });
}

// Fortune endpoint - queries fortunes from SoliDB, adds runtime fortune, sorts, renders HTML
fn fortunes(req: Any) -> Any {
let fortunes = Fortune.all();
fortunes.push({ "id": 0, "message": "Additional fortune added at request time." });
let sorted = fortunes.sort_by("message");
return render("fortunes/index", { "fortunes": sorted });
}
3 changes: 3 additions & 0 deletions frameworks/Rust/soli/app/models/fortune.sl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Fortune model for TechEmpower benchmark
class Fortune extends Model {
}
12 changes: 12 additions & 0 deletions frameworks/Rust/soli/app/views/fortunes/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head><title>Fortunes</title></head>
<body>
<table>
<tr><th>id</th><th>message</th></tr>
<% for fortune in fortunes %>
<tr><td><%= fortune["id"] %></td><td><%= fortune["message"] %></td></tr>
<% end %>
</table>
</body>
</html>
10 changes: 6 additions & 4 deletions frameworks/Rust/soli/benchmark_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
"default": {
"plaintext_url": "/plaintext",
"json_url": "/json",
"fortune_url": "/fortunes",
"port": 3000,
"approach": "Realistic",
"classification": "Platform",
"database": "None",
"classification": "Fullstack",
"framework": "soli",
"language": "Rust",
"orm": "Raw",
"database": "solidb",
"orm": "Full",
"platform": "Rust",
"webserver": "soli",
"os": "Linux",
"database_os": "Linux",
"display_name": "Soli",
"notes": "Soli MVC Framework",
"versus": "hyper"
"versus": "hyper",
"dockerfile": "soli-solidb.dockerfile"
}
}]
}
3 changes: 3 additions & 0 deletions frameworks/Rust/soli/config/routes.sl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ get("/plaintext", "bench#plaintext");

// JSON endpoint
get("/json", "bench#json");

// Fortune endpoint
get("/fortunes", "bench#fortunes");
50 changes: 50 additions & 0 deletions frameworks/Rust/soli/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
set -e

BASE="http://tfb-database:6745"

# Wait for SoliDB to be ready
echo "Waiting for SoliDB to be ready..."
echo "BASE: $BASE"

READY=false
for i in $(seq 1 60); do
if curl -sf "$BASE/_api/health" > /dev/null 2>&1; then
READY=true
break
fi
echo "Attempt $i: SoliDB not ready, retrying..."
sleep 1
done

if [ "$READY" != "true" ]; then
echo "ERROR: SoliDB did not become ready after 60 seconds"
exit 1
fi

echo "SoliDB is ready"

# Authenticate and get JWT token
TOKEN=$(curl -sf -X POST "$BASE/auth/login" \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "benchmarkdbpass"}' \
| sed -n 's/.*"token":"\([^"]*\)".*/\1/p')

# Create an API key
API_KEY=$(curl -sf -X POST "$BASE/_api/auth/api-keys" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"name": "soli-benchmark"}' \
| sed -n 's/.*"key":"\([^"]*\)".*/\1/p')

echo "API key created: ${API_KEY:0:8}..."

# Write .env file for the soli framework
cat > /app/.env <<EOF
SOLIDB_HOST=$BASE
SOLIDB_DATABASE=hello_world
SOLIDB_API_KEY=$API_KEY
EOF

echo "Starting Soli server..."
exec soli serve /app --port 3000 --workers $(($(nproc)*5/4))
25 changes: 25 additions & 0 deletions frameworks/Rust/soli/soli-solidb.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM debian:trixie-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install soli via install script
RUN curl -sSL https://raw.githubusercontent.com/solisoft/soli_lang/main/install.sh | sh

ENV PATH="/root/.local/bin:$PATH"

# Copy benchmark application files
COPY app/ /app/app/
COPY config/ /app/config/

# Copy entrypoint script
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

EXPOSE 3000

CMD ["/app/entrypoint.sh"]
24 changes: 0 additions & 24 deletions frameworks/Rust/soli/soli.dockerfile

This file was deleted.

Empty file.
89 changes: 89 additions & 0 deletions toolset/databases/solidb/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
set -e

solidb &
SOLIDB_PID=$!

BASE="http://localhost:6745"

# Wait for SoliDB to be ready
for i in $(seq 1 30); do
if curl -sf "$BASE/_api/health" > /dev/null 2>&1; then
break
fi
sleep 1
done

# Authenticate and get JWT token
TOKEN=$(curl -sf -X POST "$BASE/auth/login" \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "benchmarkdbpass"}' \
| sed -n 's/.*"token":"\([^"]*\)".*/\1/p')

AUTH="Authorization: Bearer $TOKEN"

# Create database
curl -sf -X POST "$BASE/_api/database" \
-H "Content-Type: application/json" \
-H "$AUTH" \
-d '{"name": "hello_world"}' || true

DB="$BASE/_api/database/hello_world"

# Create collections before inserting documents
curl -sf -X POST "$DB/collection" \
-H "Content-Type: application/json" \
-H "$AUTH" \
-d '{"name": "fortunes"}' || true

curl -sf -X POST "$DB/collection" \
-H "Content-Type: application/json" \
-H "$AUTH" \
-d '{"name": "worlds"}' || true

# Seeding errors should not kill the database container
set +e

# Seed fortune collection via batch insert
curl -sf -X POST "$DB/document/fortunes/_batch" \
-H "Content-Type: application/json" \
-H "$AUTH" \
-H "X-Shard-Direct: true" \
-d '[
{"id": 1, "message": "fortune: No such file or directory"},
{"id": 2, "message": "A computer scientist is someone who fixes things that aren'\''t broken."},
{"id": 3, "message": "After enough decimal places, nobody gives a damn."},
{"id": 4, "message": "A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1"},
{"id": 5, "message": "A computer program does what you tell it to do, not what you want it to do."},
{"id": 6, "message": "Emacs is a nice operating system, but I prefer UNIX. \u2014 Tom Christaensen"},
{"id": 7, "message": "Any program that runs right is obsolete."},
{"id": 8, "message": "A list is only as strong as its weakest link. \u2014 Donald Knuth"},
{"id": 9, "message": "Feature: A bug with seniority."},
{"id": 10, "message": "Computers make very fast, very accurate mistakes."},
{"id": 11, "message": "<script>alert(\"This should not be displayed in a browser alert box.\");<\/script>"},
{"id": 12, "message": "\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u30d9\u30f3\u30c1\u30de\u30fc\u30af"}
]'
echo "Fortunes seeded: exit code $?"

# Seed world collection via batch inserts (1000 docs per batch)
for batch in $(seq 0 9); do
start=$((batch * 1000 + 1))
end=$((batch * 1000 + 1000))
docs="["
for i in $(seq $start $end); do
rnd=$(( (RANDOM % 10000) + 1 ))
if [ $i -gt $start ]; then docs="$docs,"; fi
docs="$docs{\"id\":$i,\"randomNumber\":$rnd}"
done
docs="$docs]"
curl -sf -X POST "$DB/document/worlds/_batch" \
-H "Content-Type: application/json" \
-H "$AUTH" \
-H "X-Shard-Direct: true" \
-d "$docs"
echo "World batch $batch seeded: exit code $?"
done

echo "SoliDB seeding complete"

wait $SOLIDB_PID
23 changes: 23 additions & 0 deletions toolset/databases/solidb/solidb.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM debian:trixie-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /solidb

# Install solidb via install script
RUN curl -sSL https://raw.githubusercontent.com/solisoft/solidb/main/install.sh | sh

ENV PATH="/root/.local/bin:$PATH"
ENV SOLIDB_ADMIN_PASSWORD=benchmarkdbpass
ENV SOLIDB_PORT=6745
ENV SOLIDB_DATA_DIR=/data

EXPOSE 6745

COPY entrypoint.sh /solidb/entrypoint.sh
RUN chmod +x /solidb/entrypoint.sh

CMD ["/solidb/entrypoint.sh"]
Loading
Loading