| Crates.io | kairos-gateway |
| lib.rs | kairos-gateway |
| version | 0.2.13 |
| created_at | 2025-11-06 19:33:44.790061+00 |
| updated_at | 2025-11-08 14:01:38.488556+00 |
| description | High-performance HTTP API gateway built with Rust |
| homepage | |
| repository | https://github.com/DanielSarmiento04/kairos-rs |
| max_upload_size | |
| id | 1920210 |
| size | 95,339 |
High-performance multi-protocol API gateway built with Rust and Actix-Web.
kairos-gateway is the main executable binary for the Kairos API Gateway. It provides a production-ready, feature-rich gateway with support for multiple protocols including HTTP, WebSocket, FTP, and DNS.
cargo install kairos-gateway
docker pull ghcr.io/danielsarmiento04/kairos-rs:latest
git clone https://github.com/DanielSarmiento04/kairos-rs.git
cd kairos-rs
cargo build --release --bin kairos-gateway
Create a config.json file:
{
"version": 1,
"routers": [
{
"protocol": "http",
"external_path": "/api/users",
"internal_path": "/users",
"methods": ["GET", "POST"],
"backends": [
{
"host": "http://localhost",
"port": 8080,
"weight": 1
}
],
"load_balancing_strategy": "round_robin",
"auth_required": false
}
]
}
# Using binary
kairos-gateway
# Using Docker
docker run -d \
-p 5900:5900 \
-v $(pwd)/config.json:/app/config.json:ro \
ghcr.io/danielsarmiento04/kairos-rs:latest
# Using cargo
cargo run --bin kairos-gateway
# Health check
curl http://localhost:5900/health
# Test your route
curl http://localhost:5900/api/users
The gateway uses a JSON configuration file. See the main documentation for complete configuration reference.
RUST_LOG: Log level (debug, info, warn, error)KAIROS_HOST: Server host (default: 0.0.0.0)KAIROS_PORT: Server port (default: 5900)CONFIG_PATH: Path to config.json (default: ./config.json)RUST_LOG=debug KAIROS_PORT=8000 kairos-gateway
Configure load balancing strategy per route:
{
"load_balancing_strategy": "least_connections",
"backends": [
{"host": "http://backend1", "port": 8080, "weight": 2},
{"host": "http://backend2", "port": 8080, "weight": 1}
]
}
Available strategies:
round_robin: Distribute evenly across backendsleast_connections: Send to backend with fewest active connectionsrandom: Random backend selectionip_hash: Consistent hashing based on client IPAutomatic failure detection and recovery:
{
"retry": {
"max_retries": 3,
"retry_delay_ms": 100,
"backoff_multiplier": 2.0,
"circuit_breaker_threshold": 5,
"circuit_breaker_timeout_ms": 30000
}
}
Secure routes with JWT tokens:
{
"jwt": {
"secret": "your-secret-key",
"algorithm": "HS256",
"issuer": "kairos-gateway",
"audience": "api-clients"
},
"routers": [
{
"external_path": "/api/protected",
"auth_required": true
}
]
}
Protect your backends from overload:
{
"rate_limit": {
"requests_per_second": 100,
"burst_size": 200
}
}
GET /health - Overall gateway healthGET /health/ready - Readiness checkGET /health/live - Liveness checkGET /metrics - Prometheus-compatible metricsGET /metrics/requests - Request statisticsGET /metrics/backends - Backend health statusAccess the admin interface at http://localhost:5900/ (when enabled in config)
services:
kairos-gateway:
image: ghcr.io/danielsarmiento04/kairos-rs:0.2.10
container_name: kairos-gateway
restart: unless-stopped
ports:
- "5900:5900"
volumes:
- ./config.json:/app/config.json:ro
environment:
- RUST_LOG=info
- KAIROS_HOST=0.0.0.0
- KAIROS_PORT=5900
The Docker image supports both AMD64 and ARM64 architectures:
# Pull for your platform automatically
docker pull ghcr.io/danielsarmiento04/kairos-rs:latest
# Or specify platform
docker pull --platform linux/arm64 ghcr.io/danielsarmiento04/kairos-rs:latest
Benchmarks on a 4-core machine:
RUST_LOG=debug kairos-gateway
curl http://localhost:5900/metrics/backends
docker exec -it kairos-gateway sh
This crate depends on kairos-rs which provides the core gateway functionality.
Contributions are welcome! Please see the main repository for contribution guidelines.
Licensed under MIT License. See LICENSE for details.