Replace SSE price stream with WebSocket, use separate Docker port

- Replace SSE endpoint (/api/price/stream) with WebSocket (/api/price/ws)
  using ring-undertow-adapter's built-in WebSocket support
- Change Docker internal port from 4100 to 4101 to avoid conflicts with
  local dev (make run still uses 4100)
- Add free-port.sh utility script

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-23 21:32:19 +01:00
co-authored by Claude Opus 4.6
parent 6f20cd63c6
commit 9283826ac4
5 changed files with 62 additions and 60 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
# btcdata
Bitcoin data backend — Clojure Kit application. Fetches BTC prices from Binance WebSocket and Kraken HTTP, stores in PostgreSQL, exposes a JSON API with SSE price stream.
Bitcoin data backend — Clojure Kit application. Fetches BTC prices from Binance WebSocket and Kraken HTTP, stores in PostgreSQL, exposes a JSON API with WebSocket price stream.
## Build & Development Commands
@@ -44,7 +44,7 @@ Docker runs alongside local dev on different ports and databases:
## API Endpoints
- `GET /api/health` — Health check
- `GET /api/price/stream` — SSE stream with JSON price updates
- `GET /api/price/ws` — WebSocket endpoint for live JSON price updates
- `GET /api/price/latest` — Latest price as JSON
## Source Layout
@@ -67,6 +67,6 @@ src/clj/pmagnus/btcdata/
│ ├── exception.clj # Exception handling
│ └── formats.clj # Content negotiation
└── routes/
├── api.clj # /api routes (JSON + SSE)
├── api.clj # /api routes (JSON + WebSocket)
└── utils.clj # Route utilities
```