A high-throughput, low-latency WebSocket server that ingests normalised market-data quotes from pluggable feed providers and fans them out to connected clients.
┌──────────────────────────────────────────────────────────────┐
│ RTMDS Server │
│ │
│ ┌──────────┐ quotes ┌─────────────┐ fan-out │
│ │ Feed │──────────►│ Hub │──────────► [WS Clients]
│ │ (adapter)│ │(distribution)│ │
│ └──────────┘ └─────────────┘ │
│ ▲ ▲ │
│ marketdata.Feed subscribe/ │
│ interface unsubscribe │
│ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ HTTP Router (chi) │ │
│ │ GET /health GET /ready GET /ws GET /metrics │ │
│ └──────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────┘
.
├── api/ # OpenAPI 3.1 spec
├── cmd/server/ # main() entry point
├── deployments/ # Prometheus / Grafana configs
├── internal/
│ ├── app/ # DI root — wires all components
│ ├── config/ # Viper-backed config loading
│ ├── distribution/ # In-process fan-out Hub
│ ├── marketdata/ # Domain types + Feed interface
│ │ └── simulator/ # Fake feed for dev/tests
│ ├── platform/ # Logger + Prometheus metrics
│ ├── transport/ # chi router + middleware
│ └── websocket/ # Per-client WS handler
├── benchmarks/ # Benchmarking scripts and results
├── pkg/client/ # Public Go client SDK
├── scripts/ # Dev helper scripts
└── testing/
├── integration/ # End-to-end httptest tests
└── unit/ # Package-level unit tests
# 1. Download dependencies
go mod download
# 2. Run with simulator feed
make run
# 3. Subscribe to quotes (requires pip install websocket-client)
python scripts/ws_client.py --symbols AAPL TSLA MSFTmake docker-up
# Server → http://localhost:8080
# Prometheus → http://localhost:9090
# Grafana → http://localhost:3000 (admin / admin)All settings can be provided as environment variables with the RTMDS_ prefix:
| Variable | Default | Description |
|---|---|---|
RTMDS_SERVER_PORT |
8080 |
HTTP listen port |
RTMDS_REDIS_ADDR |
localhost:6379 |
Redis address |
RTMDS_FEED_SYMBOLS |
(empty) | Comma-separated symbols |
RTMDS_LOG_LEVEL |
info |
debug|info|warn|error |
RTMDS_LOG_FORMAT |
json |
json|text |
RTMDS_METRICS_ENABLED |
true |
Enable /metrics |
Or pass a YAML/TOML file: ./bin/rtmds --config config.yaml
make build Compile binary → ./bin/rtmds
make run Run locally
make test All tests (race detector + coverage)
make test-unit Unit tests only
make test-integration Integration tests only
make lint golangci-lint
make fmt gofmt
make docker-up Start full Docker Compose stack
make docker-down Tear down stack
make clean Remove build artifacts
make help Show all targets
Connect to ws://localhost:8080/ws, then send JSON commands:
// Subscribe
{ "action": "subscribe", "symbols": ["AAPL", "TSLA"] }
// Unsubscribe
{ "action": "unsubscribe", "symbols": ["AAPL"] }Received events:
{
"type": "quote",
"payload": {
"symbol": "AAPL",
"type": "trade",
"price": 182.34,
"bid": 182.33,
"ask": 182.35,
"volume": 4500,
"timestamp": "2024-11-01T14:30:00.123Z",
"provider": "simulator"
}
}See api/openapi.yaml for the full API specification.
RTMDS maintains comprehensive production documentation:
- Onboarding Guide: Repository tour and architecture reading order.
- Operations Manual: Routine maintenance, scaling, and startup/shutdown procedures.
- Security Guide: Authentication, entitlements, and secret management.
- Contributing Guide: PR workflow and contribution guidelines.
- Sequence Diagrams: Visual flow of pub/sub and replay workflows.
- Benchmarks: The canonical performance characteristics and load testing metrics.
- Create
internal/marketdata/<provider>/feed.go - Implement
marketdata.Feedinterface (Name,Subscribe,Unsubscribe,Run) - Wire it in
internal/app/app.go— replace the simulator
MIT