rstmdb-server
TCP server for rstmdb - connection handling, command dispatch, and sessions.
Overview
rstmdb-server implements the TCP server that handles client connections, authentication, and command processing. It provides TLS/mTLS support, connection pooling, and Prometheus metrics for observability.
Features
- TCP server - High-performance async server built on Tokio
- TLS/mTLS support - Secure connections with optional client certificates
- Authentication - Username/password and token-based auth
- Session management - Per-connection session state
- Prometheus metrics - Built-in
/metricsendpoint - Graceful shutdown - Clean connection draining on SIGTERM
Installation
Add to your Cargo.toml:
[]
= "0.1"
Usage
use ;
async
Configuration
use ServerConfig;
let config = ServerConfig ;
Configuration File (YAML)
bind_address: "0.0.0.0:7401"
metrics_address: "0.0.0.0:9090"
data_dir: /var/lib/rstmdb
tls:
cert: /etc/rstmdb/tls/server.crt
key: /etc/rstmdb/tls/server.key
ca: /etc/rstmdb/tls/ca.crt # Optional, for mTLS
auth:
enabled: true
users:
- username: admin
password_hash: "$argon2id$..."
storage:
max_machine_versions: 10 # Limit versions per machine (0 = unlimited)
limits:
max_connections: 1000
idle_timeout_secs: 300
Environment Variable Overrides
Configuration values can be overridden via environment variables:
RSTMDB_MAX_MACHINE_VERSIONS- Maximum versions per state machine
Prometheus Metrics
The server exposes metrics at the configured metrics address:
rstmdb_connections_total- Total connections acceptedrstmdb_connections_active- Current active connectionsrstmdb_commands_total- Commands processed by typerstmdb_command_duration_seconds- Command latency histogramrstmdb_events_applied_total- Total events appliedrstmdb_instances_total- Total instances by state machine
License
Licensed under the Business Source License 1.1. See LICENSE for details.
Part of rstmdb
This crate is part of the rstmdb state machine database. For full documentation and examples, visit the main repository.