You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use arcana_jobs::{Priority,QueuedJob};// Simple enqueue
queue.enqueue(SendEmailJob{to:"[email protected]".into(),subject:"Welcome!".into(),body:"Hello...".into(),}).await?;// With options
queue.enqueue_with(QueuedJob::new(SendEmailJob{ ...}).priority(Priority::High).delay(Duration::from_secs(300))// 5 min delay.tag("onboarding").correlation_id("user-123")).await?;// Scheduled for specific time
queue.enqueue_at(job,Utc::now() + Duration::hours(24)).await?;
# Deploy job queue components (included in the base kustomization already)
kubectl apply -k deployment/kubernetes/base/jobs/
# Workers autoscale on queue depth via the HPA; to change the bounds:
kubectl edit hpa arcana-job-worker-hpa -n arcana
# Check worker status
kubectl get pods -l component=job-worker
# View metrics (health probes and /metrics share port 8080 on job roles)
kubectl port-forward svc/arcana-job-worker 8080:8080
curl localhost:8080/metrics | grep arcana_jobs
The worker and the scheduler are the same binary as the API pods, selected by
ARCANA_DEPLOYMENT__LAYER=worker / scheduler. In monolithic deployments set
ARCANA_JOBS__ENABLED=true instead and the one process hosts both in-process.
Server-Side Rendering
sequenceDiagram
participant Client
participant Controller
participant SSR as SSR Engine
participant Cache
participant Runtime as JS Runtime Pool
Client->>Controller: GET /page
Controller->>SSR: render(template, data)
SSR->>Cache: Check cache
alt Cache Hit
Cache-->>SSR: Cached HTML
else Cache Miss
SSR->>Runtime: Acquire runtime
Runtime-->>SSR: JS Context
SSR->>Runtime: Execute render
Runtime-->>SSR: HTML output
SSR->>Cache: Store result
end
SSR-->>Controller: HTML
Controller-->>Client: 200 OK + HTML
Loading
Quick Start
Prerequisites
Rust 1.75+ with cargo
MySQL 8.0+ or PostgreSQL 15+
Docker & Docker Compose (optional)
kubectl + Kubernetes cluster (for K8s deployment)
1. Clone and Configure
git clone https://github.com/jrjohn/arcana-cloud-rust.git
cd arcana-cloud-rust
# Copy and configure environment
cp config/default.toml config/local.toml
# Edit config/local.toml with your database credentials
2. Start Dependencies
# Using Docker Compose
docker-compose -f deployment/monolithic/docker-compose.yml up -d mysql redis
# Or use existing MySQL/PostgreSQLexport ARCANA_DATABASE__URL="mysql://user:pass@localhost:3306/arcana"
3. Run Migrations and Start
# Build and run
cargo run --package arcana-server
# Or with hot reload (requires cargo-watch)
cargo install cargo-watch
cargo watch -x 'run --package arcana-server'
¹ Spring Boot estimates based on documented benchmarks (JVM with G1GC, 512MB heap)
Latency Comparison
Operation
Rust (gRPC)
Spring Boot (gRPC)
Rust Advantage
Health Check
1.07ms
~2.5ms
2.3x faster
Token Validate
1.18ms
~3.0ms
2.5x faster
Get User
2.9ms
~7.5ms
2.6x faster
Login
70ms
~150ms
2.1x faster
Throughput Under Load (50 concurrent connections)
Requests per Second (higher is better)
═══════════════════════════════════════════════════════════════════
Rust HTTP │████████████████████████████████████████████████████████████████████████████████│ 47,966
Rust gRPC │██████████████████████████████████████████████████████████████████████████████│ 38,307
Spring gRPC │████████████████████████████████████████│ ~15,000
Spring HTTP │██████████████████████████│ ~10,000
Resource Efficiency
Metric
Rust
Spring Boot
Advantage
Memory (idle)
45 MB
150 MB
Rust 3.3x lower
Memory (load)
62 MB
300 MB
Rust 4.8x lower
Startup Time
50ms
2-5s
Rust 40-100x faster
Cold Start
50ms
5-10s
Rust 100-200x faster
Binary Size
25 MB
115 MB
Rust 4.6x smaller
Winner Summary
Aspect
Rust
Spring Boot
Throughput (monolithic)
✅ 3-5x higher
Latency (p50)
✅ 2-3x lower
Latency (p99)
✅ 2-3x lower
Memory Usage
✅ 3-5x lower
Cold Start
✅ 100x faster
Ecosystem Maturity
✅ More libraries
Learning Curve
✅ Easier for Java devs
Development Speed
✅ Faster iteration
When to Choose
Use Case
Recommended
Reason
High-throughput APIs
Rust
3-5x more RPS per instance
Low-latency (< 5ms)
Rust
Consistent sub-2ms p99
Serverless/Lambda
Rust
50ms cold start vs 5s
Memory-constrained
Rust
45MB vs 300MB
Existing Java team
Spring Boot
Faster development
Enterprise integration
Spring Boot
Better ecosystem
Rapid prototyping
Spring Boot
More tooling
Key Recommendations
Scenario
Recommendation
Reason
Internal microservices
gRPC
2.5x faster than HTTP
External/browser APIs
HTTP
Browser compatibility
High concurrency
gRPC
Better connection multiplexing
Development/debugging
HTTP
Easier to inspect
Mobile backends
gRPC
Lower latency, smaller payloads
Configuration
Layered Configuration
Configuration loads from multiple sources in order (later overrides earlier):
# Application
ARCANA_ENVIRONMENT=production
ARCANA_DEPLOYMENT_MODE=layeredgrpc
# Deployment role: all | controller | service | repository | worker | scheduler
ARCANA_DEPLOYMENT__LAYER=all
# Database## Spelling rule: ONE underscore after the ARCANA prefix, TWO between config# levels. `__` separates levels, not words -- the field is `server.rest_port`,# so it is ARCANA_SERVER__REST_PORT, not ARCANA_SERVER__REST__PORT. An# unmatched variable is discarded silently and the process runs on defaults.
ARCANA_DATABASE__URL=mysql://user:pass@host:3306/arcana
ARCANA_DATABASE__MAX_CONNECTIONS=20
# Security
ARCANA_SECURITY__JWT_SECRET=your-256-bit-secret
ARCANA_SECURITY__JWT_ACCESS_EXPIRATION_SECS=3600
# Server
ARCANA_SERVER__REST_PORT=8080
ARCANA_SERVER__GRPC_PORT=9090
# Plugins
ARCANA_PLUGINS__ENABLED=true
ARCANA_PLUGINS__DIRECTORY=./plugins
# Observability
ARCANA_OBSERVABILITY__LOG_LEVEL=info
ARCANA_OBSERVABILITY__LOG_FORMAT=json
Clippy is part of the build, not a report. The rules live in Cargo.toml under [workspace.lints], and every crate opts in with [lints] workspace = true.
The Rust version is pinned in rust-toolchain.toml and every FROM rust:<version> uses the same tag, so local runs and CI see exactly the same lints. Renovate bumps them together in one "Rust toolchain" PR; any new lints are fixed in that PR.
Allow a lint only on the smallest item that needs it (one function, statement or struct), and always give a reason:
#[allow(clippy::cast_precision_loss, reason = "Redis sorted-set scores are f64; ms timestamps stay exact up to 2^53")]
Never allow a lint for a whole module or crate, and never lower a level in Cargo.toml to get a build green.
The only module-level allows are for code we do not write: tonic-build output (arcana-grpc/src/proto/mod.rs) and shaku module! expansions (arcana-server/src/di.rs).
What the pedantic lints ask for
Every public function that returns Result documents its failures in a # Errors section, and every function that can panic has a # Panics section. Write them from the code, not as filler.
Numeric as casts that can truncate, wrap or lose sign (cast_possible_truncation, cast_possible_wrap, cast_sign_loss) use TryFrom or an explicit saturating conversion instead. Silent wrap-around is a bug.
Builders and pure functions whose result must be used are #[must_use].
SonarQube also imports the Clippy JSON report (sonar.rust.clippyReport.reportPaths), so the same findings show up there.
Testing
Test Summary
Category
Count
Coverage
Unit Tests
120+
Core logic, validation
Integration Tests
30+
Service interactions
Benchmark Tests
6
Serialization performance
Total
150+
-
Running Tests
# Run all tests
cargo test# Run with output
cargo test -- --nocapture
# Run specific crate tests
cargo test --package arcana-service
# Run benchmarks
cargo bench --package arcana-server
# Generate coverage report (requires cargo-tarpaulin)
cargo install cargo-tarpaulin
cargo tarpaulin --out Html
open tarpaulin-report.html