docs(bg,en): fix ports and WebSocket example for new server model
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
- Update architecture diagram to include WebSocket server (port 9913) - Fix HTTP port from 9470 to 9912 (TCP + 440) in protocol docs - Fix WebSocket port from 9471 to 9913 (TCP + 441) in protocol docs - Fix WebSocket Nim example: remove non-existent onMessage API and unsafe cast[string](data), use correct WsServer API with safe helpers - Clarify TCP_NODELAY is also handled internally by hunos (HTTP) - Note that bytesToString/stringToBytes are wire-protocol helpers
This commit is contained in:
+13
-9
@@ -145,7 +145,7 @@ printf '\x00\x00\x00\x12\x01\x02\x00\x00\x00\x00\x08SELECT 1' > /dev/tcp/localho
|
||||
|
||||
## HTTP/REST API
|
||||
|
||||
Base URL: `http://localhost:9470/api/v1`
|
||||
Base URL: `http://localhost:9912/api/v1` (HTTP port = TCP port + 440)
|
||||
|
||||
### Rate Limiting
|
||||
|
||||
@@ -321,7 +321,7 @@ POST /admin/check
|
||||
|
||||
## WebSocket Protocol
|
||||
|
||||
URL: `ws://localhost:9471`
|
||||
URL: `ws://localhost:9913` (WebSocket port = TCP port + 441)
|
||||
|
||||
### Frame Format
|
||||
|
||||
@@ -351,7 +351,7 @@ WebSocket text frames contain JSON messages:
|
||||
### Pub/Sub Example
|
||||
|
||||
```javascript
|
||||
const ws = new WebSocket('ws://localhost:9471');
|
||||
const ws = new WebSocket('ws://localhost:9913');
|
||||
|
||||
ws.onopen = () => {
|
||||
// Subscribe to table changes
|
||||
@@ -403,7 +403,7 @@ let error = makeErrorMessage(1, 42, "Syntax error")
|
||||
```nim
|
||||
import barabadb/protocol/http
|
||||
|
||||
var router = newHttpRouter(port = 9470)
|
||||
var router = newHttpRouter(port = 9912)
|
||||
|
||||
router.get("/api/users", proc(req: Request): Future[JsonNode] {.async.} =
|
||||
return %*[
|
||||
@@ -422,11 +422,15 @@ router.post("/api/users", proc(req: Request): Future[JsonNode] {.async.} =
|
||||
```nim
|
||||
import barabadb/core/websocket
|
||||
|
||||
var server = newWsServer(port = 9471)
|
||||
server.onMessage = proc(ws: WebSocket, data: seq[byte]) {.gcsafe.} =
|
||||
echo "Received: ", cast[string](data)
|
||||
asyncCheck ws.send(cast[string](data)) # Echo
|
||||
asyncCheck server.run()
|
||||
proc bytesToString(data: seq[byte]): string =
|
||||
result = newString(data.len)
|
||||
for i in 0..<data.len:
|
||||
result[i] = char(data[i])
|
||||
|
||||
var server = newWsServer(config, secretKey)
|
||||
server.onInsert = proc(table, key, value: string) =
|
||||
echo "Insert in ", table, ": ", key
|
||||
asyncCheck server.run(9913) # WS port = TCP port + 441
|
||||
```
|
||||
|
||||
### Connection Pool
|
||||
|
||||
Reference in New Issue
Block a user