From 9b7ed1fca80b5afe8a6bced26b71f534a92e8ef5 Mon Sep 17 00:00:00 2001 From: dimgigov Date: Wed, 6 May 2026 23:23:29 +0300 Subject: [PATCH] chore: change default ports to non-standard ones (9472, 9470, 9471) --- Dockerfile | 6 ++--- README.md | 34 ++++++++++++------------- clients/javascript/baradb.js | 4 +-- clients/nim/src/baradb/client.nim | 2 +- clients/nim/tests/test_client.nim | 2 +- clients/python/baradb.py | 4 +-- clients/rust/src/lib.rs | 4 +-- docker-compose.yml | 10 ++++---- docs/bg/distributed.md | 2 +- docs/bg/installation.md | 8 +++--- docs/bg/quickstart.md | 6 ++--- docs/en/api-http.md | 16 ++++++------ docs/en/api-websocket.md | 4 +-- docs/en/backup.md | 8 +++--- docs/en/clients.md | 28 ++++++++++----------- docs/en/configuration.md | 26 +++++++++---------- docs/en/deployment.md | 42 +++++++++++++++---------------- docs/en/distributed.md | 2 +- docs/en/installation.md | 10 ++++---- docs/en/monitoring.md | 16 ++++++------ docs/en/protocol.md | 16 ++++++------ docs/en/quickstart.md | 6 ++--- docs/en/security.md | 12 ++++----- docs/en/troubleshooting.md | 18 ++++++------- src/barabadb/client/client.nim | 2 +- src/barabadb/core/config.nim | 2 +- src/barabadb/core/httpserver.nim | 2 +- src/barabadb/core/websocket.nim | 2 +- tests/test_all.nim | 38 ++++++++++++++-------------- 29 files changed, 166 insertions(+), 166 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1d628d6..7eea7d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,8 @@ COPY --from=builder /build/baradadb . RUN mkdir -p /data ENV BARADB_PORT=9000 ENV BARADB_DATA_DIR=/data -ENV BARADB_HTTP_PORT=8080 -ENV BARADB_WS_PORT=8081 -EXPOSE 9000 8080 8081 +ENV BARADB_HTTP_PORT=9470 +ENV BARADB_WS_PORT=9471 +EXPOSE 9000 9470 9471 VOLUME ["/data"] CMD ["./baradadb"] diff --git a/README.md b/README.md index 9244620..21a4a79 100644 --- a/README.md +++ b/README.md @@ -340,7 +340,7 @@ let error = makeErrorMessage(1, 42, "Syntax error") ```nim import barabadb/protocol/http -var router = newHttpRouter(port = 8080) +var router = newHttpRouter(port = 9470) router.get("/api/users", proc(req: Request): Future[JsonNode] {.async.} = return %*[{"id": 1, "name": "Alice"}]) ``` @@ -350,7 +350,7 @@ router.get("/api/users", proc(req: Request): Future[JsonNode] {.async.} = ```nim import barabadb/protocol/websocket -var server = newWsServer(port = 8081) +var server = newWsServer(port = 9471) server.onMessage = proc(ws: WebSocket, data: seq[byte]) {.gcsafe.} = echo "Received: ", cast[string](data) asyncCheck server.run() @@ -435,7 +435,7 @@ let shard = router.getShard("user_123") import barabadb/core/replication var rm = newReplicationManager(rmSync) -rm.addReplica(newReplica("r1", "10.0.0.1", 5432)) +rm.addReplica(newReplica("r1", "10.0.0.1", 9472)) rm.connectReplica("r1") let lsn = rm.writeLsn(@[1'u8, 2, 3]) rm.ackLsn("r1", lsn) # blocks until acked @@ -487,7 +487,7 @@ nim c -d:ssl -d:release -r benchmarks/bench_all.nim ```bash docker build -t baradb . -docker run -p 5432:5432 -p 8080:8080 -p 8081:8081 -v baradb_data:/data baradb +docker run -p 9472:9472 -p 9470:9470 -p 9471:9471 -v baradb_data:/data baradb ``` ### Docker Compose @@ -500,9 +500,9 @@ docker-compose up -d | Variable | Default | Description | |----------|---------|-------------| -| `BARADB_PORT` | `5432` | TCP binary protocol port | -| `BARADB_HTTP_PORT` | `8080` | HTTP/REST API port | -| `BARADB_WS_PORT` | `8081` | WebSocket port | +| `BARADB_PORT` | `9472` | TCP binary protocol port | +| `BARADB_HTTP_PORT` | `9470` | HTTP/REST API port | +| `BARADB_WS_PORT` | `9471` | WebSocket port | | `BARADB_DATA_DIR` | `./data` | Data directory | | `BARADB_TLS_ENABLED` | `false` | Enable TLS | | `BARADB_CERT_FILE` | — | TLS certificate path | @@ -520,7 +520,7 @@ npm install baradb ```javascript import { Client } from 'baradb'; -const client = new Client('localhost', 5432); +const client = new Client('localhost', 9472); await client.connect(); const result = await client.query("SELECT name FROM users WHERE age > 18"); console.log(result.rows); @@ -535,7 +535,7 @@ pip install baradb ```python from baradb import Client -client = Client("localhost", 5432) +client = Client("localhost", 9472) client.connect() result = client.query("SELECT name FROM users WHERE age > 18") print(result.rows) @@ -562,7 +562,7 @@ baradb = "0.1" ```rust use baradb::Client; -let mut client = Client::connect("localhost:5432").await?; +let mut client = Client::connect("localhost:9472").await?; let result = client.query("SELECT name FROM users").await?; ``` @@ -607,15 +607,15 @@ BaraDB can be configured via environment variables or a config file: ```bash # Environment variables -export BARADB_PORT=5432 -export BARADB_HTTP_PORT=8080 +export BARADB_PORT=9472 +export BARADB_HTTP_PORT=9470 export BARADB_DATA_DIR=/var/lib/baradb export BARADB_LOG_LEVEL=info export BARADB_COMPACTION_INTERVAL=60000 # Or create baradb.conf -port = 5432 -http_port = 8080 +port = 9472 +http_port = 9470 data_dir = "/var/lib/baradb" log_level = "info" compaction_interval_ms = 60000 @@ -628,7 +628,7 @@ compaction_interval_ms = 60000 BaraDB exposes operational metrics via the HTTP API: ```bash -curl http://localhost:8080/metrics +curl http://localhost:9470/metrics ``` Example response: @@ -650,7 +650,7 @@ Example response: ### Health Check ```bash -curl http://localhost:8080/health +curl http://localhost:9470/health ``` ### Logging @@ -997,7 +997,7 @@ Error: unhandled exception: Address already in use ```bash BARADB_PORT=5433 ./build/baradadb # or -lsof -ti:5432 | xargs kill -9 +lsof -ti:9472 | xargs kill -9 ``` ### SSL Compilation Error diff --git a/clients/javascript/baradb.js b/clients/javascript/baradb.js index 3459711..d5de9a3 100644 --- a/clients/javascript/baradb.js +++ b/clients/javascript/baradb.js @@ -9,7 +9,7 @@ * * Quick Start: * import { Client } from 'baradb'; - * const client = new Client('localhost', 5432); + * const client = new Client('localhost', 9472); * await client.connect(); * const result = await client.query('SELECT name FROM users WHERE age > 18'); * for (const row of result) { @@ -87,7 +87,7 @@ class QueryResult { } class Client { - constructor(host = 'localhost', port = 5432, options = {}) { + constructor(host = 'localhost', port = 9472, options = {}) { this.host = host; this.port = port; this.database = options.database || 'default'; diff --git a/clients/nim/src/baradb/client.nim b/clients/nim/src/baradb/client.nim index 83f9f72..6f04aff 100644 --- a/clients/nim/src/baradb/client.nim +++ b/clients/nim/src/baradb/client.nim @@ -241,7 +241,7 @@ type proc defaultConfig*(): ClientConfig = ClientConfig( - host: "127.0.0.1", port: 5432, database: "default", + host: "127.0.0.1", port: 9472, database: "default", username: "admin", password: "", timeoutMs: 30000, maxRetries: 3, ) diff --git a/clients/nim/tests/test_client.nim b/clients/nim/tests/test_client.nim index 5a1cca7..8f6070a 100644 --- a/clients/nim/tests/test_client.nim +++ b/clients/nim/tests/test_client.nim @@ -65,7 +65,7 @@ suite "Client Config": test "Default config": let config = defaultConfig() check config.host == "127.0.0.1" - check config.port == 5432 + check config.port == 9472 check config.database == "default" test "Custom config": diff --git a/clients/python/baradb.py b/clients/python/baradb.py index cc5cf2c..bca97ac 100644 --- a/clients/python/baradb.py +++ b/clients/python/baradb.py @@ -9,7 +9,7 @@ Install: Quick Start: from baradb import Client - client = Client("localhost", 5432) + client = Client("localhost", 9472) client.connect() result = client.query("SELECT name FROM users WHERE age > 18") for row in result: @@ -106,7 +106,7 @@ class QueryResult: class Client: """BaraDB database client.""" - def __init__(self, host: str = "localhost", port: int = 5432, + def __init__(self, host: str = "localhost", port: int = 9472, database: str = "default", username: str = "admin", password: str = "", timeout: int = 30): self.host = host diff --git a/clients/rust/src/lib.rs b/clients/rust/src/lib.rs index 157f3a7..b18b8bd 100644 --- a/clients/rust/src/lib.rs +++ b/clients/rust/src/lib.rs @@ -6,7 +6,7 @@ //! ```no_run //! use baradb::Client; //! -//! let mut client = Client::connect("localhost", 5432).unwrap(); +//! let mut client = Client::connect("localhost", 9472).unwrap(); //! let result = client.query("SELECT name FROM users WHERE age > 18").unwrap(); //! for row in result.rows() { //! println!("{}", row["name"]); @@ -54,7 +54,7 @@ impl Default for Config { fn default() -> Self { Config { host: "127.0.0.1".to_string(), - port: 5432, + port: 9472, database: "default".to_string(), username: "admin".to_string(), password: String::new(), diff --git a/docker-compose.yml b/docker-compose.yml index 6c9011f..02685f8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,17 +4,17 @@ services: build: . ports: - "9000:9000" - - "8080:8080" - - "8081:8081" + - "9470:9470" + - "9471:9471" volumes: - baradb_data:/data environment: - BARADB_PORT=9000 - BARADB_DATA_DIR=/data - - BARADB_HTTP_PORT=8080 - - BARADB_WS_PORT=8081 + - BARADB_HTTP_PORT=9470 + - BARADB_WS_PORT=9471 healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/health"] + test: ["CMD", "wget", "-q", "--spider", "http://localhost:9470/health"] interval: 10s timeout: 5s retries: 3 diff --git a/docs/bg/distributed.md b/docs/bg/distributed.md index 0a23c02..2081895 100644 --- a/docs/bg/distributed.md +++ b/docs/bg/distributed.md @@ -32,6 +32,6 @@ let shard = router.getShard("user_123") import barabadb/core/replication var rm = newReplicationManager(rmSync) -rm.addReplica(newReplica("r1", "10.0.0.1", 5432)) +rm.addReplica(newReplica("r1", "10.0.0.1", 9472)) rm.connectReplica("r1") ``` \ No newline at end of file diff --git a/docs/bg/installation.md b/docs/bg/installation.md index 488477d..dd5dcdb 100644 --- a/docs/bg/installation.md +++ b/docs/bg/installation.md @@ -159,9 +159,9 @@ sudo mkdir -p /var/lib/baradb ```bash docker pull barabadb/barabadb:latest docker run -d \ - -p 5432:5432 \ - -p 8080:8080 \ - -p 8081:8081 \ + -p 9472:9472 \ + -p 9470:9470 \ + -p 9471:9471 \ -v baradb_data:/data \ barabadb/barabadb ``` @@ -194,7 +194,7 @@ db.close() ./build/baradadb # Тестване на HTTP API -curl http://localhost:8080/health +curl http://localhost:9470/health # Интерактивна конзола ./build/baradadb --shell diff --git a/docs/bg/quickstart.md b/docs/bg/quickstart.md index 7292395..5ae325f 100644 --- a/docs/bg/quickstart.md +++ b/docs/bg/quickstart.md @@ -8,7 +8,7 @@ ./build/baradadb ``` -Сървърът ще стартира на `localhost:8080` по подразбиране. +Сървърът ще стартира на `localhost:9470` по подразбиране. ## Свързване чрез CLI @@ -102,10 +102,10 @@ SELECT * FROM vectors ORDER BY cosine_distance(embedding, [0.1, 0.2, 0.3]) LIMIT ```bash # GET заявка -curl http://localhost:8080/api/users +curl http://localhost:9470/api/users # POST заявка -curl -X POST http://localhost:8080/api/users \ +curl -X POST http://localhost:9470/api/users \ -H "Content-Type: application/json" \ -d '{"name": "Alice", "age": 30}' ``` diff --git a/docs/en/api-http.md b/docs/en/api-http.md index 15a18d8..cdba623 100644 --- a/docs/en/api-http.md +++ b/docs/en/api-http.md @@ -5,7 +5,7 @@ JSON-based REST API for web applications. ## Base URL ``` -http://localhost:8080/api +http://localhost:9470/api ``` ## Endpoints @@ -15,7 +15,7 @@ http://localhost:8080/api List all users: ```bash -curl http://localhost:8080/api/users +curl http://localhost:9470/api/users ``` Response: @@ -31,7 +31,7 @@ Response: Get user by ID: ```bash -curl http://localhost:8080/api/users/1 +curl http://localhost:9470/api/users/1 ``` ### POST /api/users @@ -39,7 +39,7 @@ curl http://localhost:8080/api/users/1 Create user: ```bash -curl -X POST http://localhost:8080/api/users \ +curl -X POST http://localhost:9470/api/users \ -H "Content-Type: application/json" \ -d '{"name": "Charlie", "age": 35}' ``` @@ -49,7 +49,7 @@ curl -X POST http://localhost:8080/api/users \ Update user: ```bash -curl -X PUT http://localhost:8080/api/users/1 \ +curl -X PUT http://localhost:9470/api/users/1 \ -H "Content-Type: application/json" \ -d '{"name": "Alice", "age": 31}' ``` @@ -59,7 +59,7 @@ curl -X PUT http://localhost:8080/api/users/1 \ Delete user: ```bash -curl -X DELETE http://localhost:8080/api/users/1 +curl -X DELETE http://localhost:9470/api/users/1 ``` ## Query Endpoint @@ -67,7 +67,7 @@ curl -X DELETE http://localhost:8080/api/users/1 Execute BaraQL queries via HTTP: ```bash -curl -X POST http://localhost:8080/api/query \ +curl -X POST http://localhost:9470/api/query \ -H "Content-Type: application/json" \ -d '{"sql": "SELECT * FROM users WHERE age > 18"}' ``` @@ -87,5 +87,5 @@ curl -X POST http://localhost:8080/api/query \ ```bash curl -H "Authorization: Bearer " \ - http://localhost:8080/api/users + http://localhost:9470/api/users ``` \ No newline at end of file diff --git a/docs/en/api-websocket.md b/docs/en/api-websocket.md index 39fe55f..99c18c1 100644 --- a/docs/en/api-websocket.md +++ b/docs/en/api-websocket.md @@ -5,13 +5,13 @@ Full-duplex streaming for real-time data feeds and push notifications. ## Connection ``` -ws://localhost:8081/ws +ws://localhost:9471/ws ``` ## Client Example ```javascript -const ws = new WebSocket('ws://localhost:8081/ws'); +const ws = new WebSocket('ws://localhost:9471/ws'); ws.onopen = () => { console.log('Connected'); diff --git a/docs/en/backup.md b/docs/en/backup.md index 8c488a0..56202eb 100644 --- a/docs/en/backup.md +++ b/docs/en/backup.md @@ -23,7 +23,7 @@ bm.createSnapshot("/backup/baradb_2025-01-15") ### Via HTTP API ```bash -curl -X POST http://localhost:8080/api/backup \ +curl -X POST http://localhost:9470/api/backup \ -H "Content-Type: application/json" \ -d '{"destination": "/backup/snapshot.db"}' ``` @@ -101,7 +101,7 @@ BARADB_REPLICATION_MODE=async \ ```bash BARADB_REPLICATION_ENABLED=true \ -BARADB_REPLICATION_PRIMARY=primary:5432 \ +BARADB_REPLICATION_PRIMARY=primary:9472 \ ./build/baradadb ``` @@ -130,7 +130,7 @@ cp /backup/snapshot.db ./data/ ./build/baradadb --recover --wal-dir=/backup/wal # 3. Verify -curl http://localhost:8080/health +curl http://localhost:9470/health ``` #### Scenario 3: Cluster Node Failure @@ -155,7 +155,7 @@ Always verify backups: --data-dir=/tmp/verify_data # Run consistency check -curl http://localhost:8080/api/admin/check +curl http://localhost:9470/api/admin/check ``` ## Storage Requirements diff --git a/docs/en/clients.md b/docs/en/clients.md index 321438a..739896c 100644 --- a/docs/en/clients.md +++ b/docs/en/clients.md @@ -17,7 +17,7 @@ yarn add baradb ```typescript import { Client } from 'baradb'; -const client = new Client('localhost', 5432); +const client = new Client('localhost', 9472); await client.connect(); // Simple query @@ -50,7 +50,7 @@ await client.close(); ```typescript import { WebSocketClient } from 'baradb/ws'; -const ws = new WebSocketClient('ws://localhost:8081'); +const ws = new WebSocketClient('ws://localhost:9471'); ws.onMessage = (data) => console.log(data); await ws.connect(); await ws.send('SUBSCRIBE updates'); @@ -69,7 +69,7 @@ pip install baradb ```python from baradb import Client -client = Client("localhost", 5432) +client = Client("localhost", 9472) client.connect() # Simple query @@ -90,7 +90,7 @@ client.batch([ ]) # Context manager (auto-close) -with Client("localhost", 5432) as c: +with Client("localhost", 9472) as c: result = c.query("SELECT count(*) FROM users") print(result[0]["count"]) ``` @@ -102,7 +102,7 @@ import asyncio from baradb import AsyncClient async def main(): - client = AsyncClient("localhost", 5432) + client = AsyncClient("localhost", 9472) await client.connect() result = await client.query("SELECT * FROM users") print(result.rows) @@ -157,7 +157,7 @@ let path = g.shortestPath(alice, bob) ```nim import barabadb/client/client -var c = newBaraClient("localhost", 5432) +var c = newBaraClient("localhost", 9472) c.connect() let result = c.query("SELECT name FROM users") for row in result.rows: @@ -182,7 +182,7 @@ use baradb::Client; #[tokio::main] async fn main() -> Result<(), Box> { - let mut client = Client::connect("localhost:5432").await?; + let mut client = Client::connect("localhost:9472").await?; let result = client .query("SELECT name, age FROM users WHERE age > 18") @@ -203,24 +203,24 @@ All languages can use the HTTP/REST API directly: ```bash # Query -curl -X POST http://localhost:8080/api/query \ +curl -X POST http://localhost:9470/api/query \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $TOKEN" \ -d '{"query": "SELECT * FROM users WHERE age > 18"}' # Insert -curl -X POST http://localhost:8080/api/query \ +curl -X POST http://localhost:9470/api/query \ -H "Content-Type: application/json" \ -d '{"query": "INSERT users { name := \"Alice\", age := 30 }"}' # Schema -curl http://localhost:8080/api/schema +curl http://localhost:9470/api/schema # Health -curl http://localhost:8080/health +curl http://localhost:9470/health # Metrics -curl http://localhost:8080/metrics +curl http://localhost:9470/metrics ``` ## Connection Pooling @@ -234,7 +234,7 @@ import { Pool } from 'baradb'; const pool = new Pool({ host: 'localhost', - port: 5432, + port: 9472, min: 5, max: 50, idleTimeout: 30000, @@ -253,7 +253,7 @@ try { ```python from baradb import Pool -pool = Pool("localhost", 5432, min_size=5, max_size=50) +pool = Pool("localhost", 9472, min_size=5, max_size=50) with pool.connection() as conn: result = conn.query("SELECT 1") ``` diff --git a/docs/en/configuration.md b/docs/en/configuration.md index 639950c..ff9e433 100644 --- a/docs/en/configuration.md +++ b/docs/en/configuration.md @@ -16,9 +16,9 @@ BaraDB can be configured via **environment variables**, a **config file**, or ** | Variable | Default | Description | |----------|---------|-------------| | `BARADB_ADDRESS` | `127.0.0.1` | Bind address | -| `BARADB_PORT` | `5432` | TCP binary protocol port | -| `BARADB_HTTP_PORT` | `8080` | HTTP/REST API port | -| `BARADB_WS_PORT` | `8081` | WebSocket port | +| `BARADB_PORT` | `9472` | TCP binary protocol port | +| `BARADB_HTTP_PORT` | `9470` | HTTP/REST API port | +| `BARADB_WS_PORT` | `9471` | WebSocket port | ### Storage @@ -89,9 +89,9 @@ BaraDB can be configured via **environment variables**, a **config file**, or ** ```ini [server] address = "0.0.0.0" -port = 5432 -http_port = 8080 -ws_port = 8081 +port = 9472 +http_port = 9470 +ws_port = 9471 [storage] data_dir = "/var/lib/baradb" @@ -132,9 +132,9 @@ raft_peers = "node2:9001,node3:9001" { "server": { "address": "0.0.0.0", - "port": 5432, - "http_port": 8080, - "ws_port": 8081 + "port": 9472, + "http_port": 9470, + "ws_port": 9471 }, "storage": { "data_dir": "/var/lib/baradb", @@ -163,9 +163,9 @@ Usage: Options: -c, --config Config file path - -p, --port TCP binary port (default: 5432) - --http-port HTTP port (default: 8080) - --ws-port WebSocket port (default: 8081) + -p, --port TCP binary port (default: 9472) + --http-port HTTP port (default: 9470) + --ws-port WebSocket port (default: 9471) -d, --data-dir Data directory (default: ./data) --tls-cert TLS certificate file --tls-key TLS private key file @@ -208,7 +208,7 @@ BARADB_CACHE_SIZE_MB=1024 \ ```bash # Node 1 BARADB_ADDRESS=0.0.0.0 \ -BARADB_PORT=5432 \ +BARADB_PORT=9472 \ BARADB_RAFT_NODE_ID=node1 \ BARADB_RAFT_PEERS=node2:9001,node3:9001 \ BARADB_SHARD_COUNT=4 \ diff --git a/docs/en/deployment.md b/docs/en/deployment.md index 658cee9..9185ca3 100644 --- a/docs/en/deployment.md +++ b/docs/en/deployment.md @@ -8,9 +8,9 @@ docker build -t baradb:latest . docker run -d \ --name baradb \ - -p 5432:5432 \ - -p 8080:8080 \ - -p 8081:8081 \ + -p 9472:9472 \ + -p 9470:9470 \ + -p 9471:9471 \ -v baradb_data:/data \ -e BARADB_DATA_DIR=/data \ baradb:latest @@ -24,16 +24,16 @@ services: baradb: image: baradb:latest ports: - - "5432:5432" - - "8080:8080" - - "8081:8081" + - "9472:9472" + - "9470:9470" + - "9471:9471" volumes: - baradb_data:/data - ./certs:/certs:ro environment: - - BARADB_PORT=5432 - - BARADB_HTTP_PORT=8080 - - BARADB_WS_PORT=8081 + - BARADB_PORT=9472 + - BARADB_HTTP_PORT=9470 + - BARADB_WS_PORT=9471 - BARADB_DATA_DIR=/data - BARADB_TLS_ENABLED=true - BARADB_CERT_FILE=/certs/server.crt @@ -42,7 +42,7 @@ services: - BARADB_MEMTABLE_SIZE_MB=256 - BARADB_CACHE_SIZE_MB=512 healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/health"] + test: ["CMD", "wget", "-q", "--spider", "http://localhost:9470/health"] interval: 10s timeout: 5s retries: 3 @@ -84,8 +84,8 @@ ExecStart=/usr/local/bin/baradadb Restart=always RestartSec=5 -Environment=BARADB_PORT=5432 -Environment=BARADB_HTTP_PORT=8080 +Environment=BARADB_PORT=9472 +Environment=BARADB_HTTP_PORT=9470 Environment=BARADB_DATA_DIR=/var/lib/baradb/data Environment=BARADB_LOG_LEVEL=info @@ -137,11 +137,11 @@ spec: - name: baradb image: baradb:latest ports: - - containerPort: 5432 + - containerPort: 9472 name: binary - - containerPort: 8080 + - containerPort: 9470 name: http - - containerPort: 8081 + - containerPort: 9471 name: websocket env: - name: BARADB_DATA_DIR @@ -170,11 +170,11 @@ spec: selector: app: baradb ports: - - port: 5432 + - port: 9472 name: binary - - port: 8080 + - port: 9470 name: http - - port: 8081 + - port: 9471 name: websocket clusterIP: None ``` @@ -183,11 +183,11 @@ spec: ```nginx upstream baradb_http { - server 127.0.0.1:8080; + server 127.0.0.1:9470; } upstream baradb_ws { - server 127.0.0.1:8081; + server 127.0.0.1:9471; } server { @@ -277,7 +277,7 @@ systemctl enable --now baradb ```bash gcloud run deploy baradb \ --image gcr.io/PROJECT/baradb \ - --port 8080 \ + --port 9470 \ --memory 4Gi \ --cpu 2 \ --max-instances 10 diff --git a/docs/en/distributed.md b/docs/en/distributed.md index 636e59b..c9ee6fd 100644 --- a/docs/en/distributed.md +++ b/docs/en/distributed.md @@ -50,7 +50,7 @@ let shard = router.getShard("user_123") import barabadb/core/replication var rm = newReplicationManager(rmSync) -rm.addReplica(newReplica("r1", "10.0.0.1", 5432)) +rm.addReplica(newReplica("r1", "10.0.0.1", 9472)) rm.connectReplica("r1") let lsn = rm.writeLsn(@[1'u8, 2, 3]) rm.ackLsn("r1", lsn) diff --git a/docs/en/installation.md b/docs/en/installation.md index 901f194..9c39e8e 100644 --- a/docs/en/installation.md +++ b/docs/en/installation.md @@ -220,9 +220,9 @@ docker pull barabadb/barabadb:latest # Run docker run -d \ - -p 5432:5432 \ - -p 8080:8080 \ - -p 8081:8081 \ + -p 9472:9472 \ + -p 9470:9470 \ + -p 9471:9471 \ -v baradb_data:/data \ barabadb/barabadb ``` @@ -260,10 +260,10 @@ db.close() # Expected output: # BaraDB v0.1.0 — Multimodal Database Engine -# BaraDB TCP listening on 127.0.0.1:5432 +# BaraDB TCP listening on 127.0.0.1:9472 # Test with HTTP API -curl http://localhost:8080/health +curl http://localhost:9470/health # Interactive shell ./build/baradadb --shell diff --git a/docs/en/monitoring.md b/docs/en/monitoring.md index c90bdcc..5a49ac2 100644 --- a/docs/en/monitoring.md +++ b/docs/en/monitoring.md @@ -5,7 +5,7 @@ ### HTTP Health Endpoint ```bash -curl http://localhost:8080/health +curl http://localhost:9470/health ``` Response: @@ -26,7 +26,7 @@ Response: ### Readiness Probe ```bash -curl http://localhost:8080/ready +curl http://localhost:9470/ready ``` Returns `200 OK` when the server is ready to accept traffic, `503` during startup. @@ -36,7 +36,7 @@ Returns `200 OK` when the server is ready to accept traffic, `503` during startu ### Prometheus-Compatible Metrics ```bash -curl http://localhost:8080/metrics +curl http://localhost:9470/metrics ``` Example output: @@ -80,7 +80,7 @@ baradb_txns_committed_total 89123 ### JSON Metrics ```bash -curl http://localhost:8080/metrics?format=json +curl http://localhost:9470/metrics?format=json ``` ## Logging @@ -190,7 +190,7 @@ Key panels: For Raft clusters, monitor: ```bash -curl http://node1:8080/metrics/cluster +curl http://node1:9470/metrics/cluster ``` ```json @@ -213,19 +213,19 @@ curl http://node1:8080/metrics/cluster ### Built-in CPU Profiler ```bash -curl -X POST http://localhost:8080/debug/pprof/cpu?seconds=30 > cpu.prof +curl -X POST http://localhost:9470/debug/pprof/cpu?seconds=30 > cpu.prof ``` ### Memory Profiler ```bash -curl http://localhost:8080/debug/pprof/heap > heap.prof +curl http://localhost:9470/debug/pprof/heap > heap.prof ``` ### Trace ```bash -curl -X POST http://localhost:8080/debug/pprof/trace?seconds=5 > trace.out +curl -X POST http://localhost:9470/debug/pprof/trace?seconds=5 > trace.out ``` ## Log Aggregation diff --git a/docs/en/protocol.md b/docs/en/protocol.md index 8853998..fcd0d81 100644 --- a/docs/en/protocol.md +++ b/docs/en/protocol.md @@ -120,18 +120,18 @@ Every message starts with a 8-byte header: ```bash # Connect -nc localhost 5432 +nc localhost 9472 # Send: Auth request (token "mytoken") # Header: length=15, type=0x07, seq=1 # Payload: token length=7, token="mytoken" -printf '\x00\x00\x00\x0f\x07\x01\x00\x00\x00\x07mytoken' > /dev/tcp/localhost/5432 +printf '\x00\x00\x00\x0f\x07\x01\x00\x00\x00\x07mytoken' > /dev/tcp/localhost/9472 # Receive: Auth_OK # \x00\x00\x00\x06\x83\x01 # Send: Query "SELECT 1" -printf '\x00\x00\x00\x12\x01\x02\x00\x00\x00\x00\x08SELECT 1' > /dev/tcp/localhost/5432 +printf '\x00\x00\x00\x12\x01\x02\x00\x00\x00\x00\x08SELECT 1' > /dev/tcp/localhost/9472 # Receive: Data + Complete ``` @@ -140,7 +140,7 @@ printf '\x00\x00\x00\x12\x01\x02\x00\x00\x00\x00\x08SELECT 1' > /dev/tcp/localho ## HTTP/REST API -Base URL: `http://localhost:8080/api/v1` +Base URL: `http://localhost:9470/api/v1` ### Endpoints @@ -304,7 +304,7 @@ POST /admin/check ## WebSocket Protocol -URL: `ws://localhost:8081` +URL: `ws://localhost:9471` ### Frame Format @@ -334,7 +334,7 @@ WebSocket text frames contain JSON messages: ### Pub/Sub Example ```javascript -const ws = new WebSocket('ws://localhost:8081'); +const ws = new WebSocket('ws://localhost:9471'); ws.onopen = () => { // Subscribe to table changes @@ -386,7 +386,7 @@ let error = makeErrorMessage(1, 42, "Syntax error") ```nim import barabadb/protocol/http -var router = newHttpRouter(port = 8080) +var router = newHttpRouter(port = 9470) router.get("/api/users", proc(req: Request): Future[JsonNode] {.async.} = return %*[ @@ -405,7 +405,7 @@ router.post("/api/users", proc(req: Request): Future[JsonNode] {.async.} = ```nim import barabadb/core/websocket -var server = newWsServer(port = 8081) +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 diff --git a/docs/en/quickstart.md b/docs/en/quickstart.md index d2cee95..0304697 100644 --- a/docs/en/quickstart.md +++ b/docs/en/quickstart.md @@ -8,7 +8,7 @@ After building BaraDB, start the server: ./build/baradadb ``` -The server will start on `localhost:8080` by default. +The server will start on `localhost:9470` by default. ## Connecting via CLI @@ -118,10 +118,10 @@ SELECT * FROM articles WHERE MATCH(title, body) AGAINST('database'); ```bash # GET request -curl http://localhost:8080/api/users +curl http://localhost:9470/api/users # POST request -curl -X POST http://localhost:8080/api/users \ +curl -X POST http://localhost:9470/api/users \ -H "Content-Type: application/json" \ -d '{"name": "Alice", "age": 30}' ``` diff --git a/docs/en/security.md b/docs/en/security.md index 44c4484..1d21a4c 100644 --- a/docs/en/security.md +++ b/docs/en/security.md @@ -40,7 +40,7 @@ BARADB_KEY_FILE=/etc/letsencrypt/live/db.example.com/privkey.pem \ ```python from baradb import Client -client = Client("localhost", 5432, tls=True, tls_verify=True) +client = Client("localhost", 9472, tls=True, tls_verify=True) client.connect() ``` @@ -84,14 +84,14 @@ let token = am.createToken(JWTClaims( ```bash curl -H "Authorization: Bearer $TOKEN" \ - http://localhost:8080/api/query \ + http://localhost:9470/api/query \ -d '{"query": "SELECT * FROM users"}' ``` ```python from baradb import Client -client = Client("localhost", 5432) +client = Client("localhost", 9472) client.connect() client.authenticate("eyJhbGciOiJIUzI1NiIs...") ``` @@ -143,11 +143,11 @@ BARADB_ADDRESS=10.0.0.5 ./build/baradadb ```bash # Allow only application servers -sudo ufw allow from 10.0.0.0/8 to any port 5432 -sudo ufw allow from 10.0.0.0/8 to any port 8080 +sudo ufw allow from 10.0.0.0/8 to any port 9472 +sudo ufw allow from 10.0.0.0/8 to any port 9470 # Block external access to management ports -sudo ufw deny 8081 # WebSocket (internal use only) +sudo ufw deny 9471 # WebSocket (internal use only) ``` ## Data Encryption at Rest diff --git a/docs/en/troubleshooting.md b/docs/en/troubleshooting.md index 2dcf442..986ccfc 100644 --- a/docs/en/troubleshooting.md +++ b/docs/en/troubleshooting.md @@ -60,9 +60,9 @@ BARADB_PORT=5433 ./build/baradadb **Solution 2:** Kill existing process: ```bash -lsof -ti:5432 | xargs kill -9 +lsof -ti:9472 | xargs kill -9 # or -fuser -k 5432/tcp +fuser -k 9472/tcp ``` ### Permission Denied on Data Directory @@ -108,7 +108,7 @@ Error: No space left on device df -h # Trigger compaction to reclaim space -curl -X POST http://localhost:8080/api/admin/compact +curl -X POST http://localhost:9470/api/admin/compact # Or manually ./build/baradadb --compact @@ -184,7 +184,7 @@ SELECT * FROM users WHERE id = 123; ### Connection Refused ``` -Connection refused: localhost:5432 +Connection refused: localhost:9472 ``` **Solution:** @@ -198,7 +198,7 @@ ps aux | grep baradadb # Check firewall sudo ufw status -sudo ufw allow 5432 +sudo ufw allow 9472 ``` ### Authentication Failed @@ -247,7 +247,7 @@ BARADB_KEY_FILE=/path/to/key.pem \ ```bash # Check query plan -curl -X POST http://localhost:8080/api/explain \ +curl -X POST http://localhost:9470/api/explain \ -d '{"query": "SELECT * FROM large_table"}' ``` @@ -292,7 +292,7 @@ LIMIT 10; **Monitor:** ```bash -curl http://localhost:8080/metrics | grep memory +curl http://localhost:9470/metrics | grep memory ``` **Solutions:** @@ -347,7 +347,7 @@ Warning: Shard 3 has 2× data of others ```bash # Trigger rebalancing -curl -X POST http://localhost:8080/api/admin/rebalance +curl -X POST http://localhost:9470/api/admin/rebalance ``` ## Data Corruption @@ -399,7 +399,7 @@ BARADB_LOG_FILE=/tmp/baradb_debug.log \ If the issue persists: 1. Check logs: `tail -f /var/log/baradb/baradb.log` -2. Check metrics: `curl http://localhost:8080/metrics` +2. Check metrics: `curl http://localhost:9470/metrics` 3. Run diagnostics: `./build/baradadb --diagnose` 4. Open an issue with: - BaraDB version (`./build/baradadb --version`) diff --git a/src/barabadb/client/client.nim b/src/barabadb/client/client.nim index 741a617..99d4474 100644 --- a/src/barabadb/client/client.nim +++ b/src/barabadb/client/client.nim @@ -30,7 +30,7 @@ type proc defaultClientConfig*(): ClientConfig = ClientConfig( host: "127.0.0.1", - port: 5432, + port: 9472, database: "default", username: "admin", password: "", diff --git a/src/barabadb/core/config.nim b/src/barabadb/core/config.nim index 7d3eaba..414a0c9 100644 --- a/src/barabadb/core/config.nim +++ b/src/barabadb/core/config.nim @@ -21,7 +21,7 @@ type proc defaultConfig*(): BaraConfig = BaraConfig( address: "127.0.0.1", - port: 5432, + port: 9472, dataDir: "./data", maxConnections: 1000, walEnabled: true, diff --git a/src/barabadb/core/httpserver.nim b/src/barabadb/core/httpserver.nim index ceba4e7..4f6fee0 100644 --- a/src/barabadb/core/httpserver.nim +++ b/src/barabadb/core/httpserver.nim @@ -441,7 +441,7 @@ setInterval(() => { if(document.querySelectorAll('.panel')[4].classList.contains """ request.respond(200, @[("Content-Type", "text/html; charset=utf-8")], html) -proc run*(server: HttpServer, port: int = 8080) = +proc run*(server: HttpServer, port: int = 9470) = var router = newRouter() router.get("/admin", server.adminHandler()) router.get("/", server.adminHandler()) diff --git a/src/barabadb/core/websocket.nim b/src/barabadb/core/websocket.nim index d42f4e9..d0d99df 100644 --- a/src/barabadb/core/websocket.nim +++ b/src/barabadb/core/websocket.nim @@ -283,7 +283,7 @@ proc handleConnection(server: WsServer, client: AsyncSocket) {.async.} = inc server.nextId asyncCheck server.handleWsClient(client, server.nextId) -proc run*(server: WsServer, port: int = 8081) {.async.} = +proc run*(server: WsServer, port: int = 9471) {.async.} = server.running = true let sock = newAsyncSocket() sock.setSockOpt(OptReuseAddr, true) diff --git a/tests/test_all.nim b/tests/test_all.nim index 5f1ed6d..e856217 100644 --- a/tests/test_all.nim +++ b/tests/test_all.nim @@ -665,18 +665,18 @@ suite "Type Checker & IR": suite "Connection Pool": test "Create pool and acquire connection": - var pool = newConnectionPool("127.0.0.1", 5432) + var pool = newConnectionPool("127.0.0.1", 9472) let conn = pool.acquire() check conn != nil check conn.host == "127.0.0.1" - check conn.port == 5432 + check conn.port == 9472 pool.release(conn) test "Pool stats": var cfg = defaultPoolConfig() cfg.minConnections = 1 cfg.maxConnections = 10 - var pool = newConnectionPool("127.0.0.1", 5432, "default", cfg) + var pool = newConnectionPool("127.0.0.1", 9472, "default", cfg) let conn1 = pool.acquire() let (total, idle, inUse) = pool.stats() check inUse == 1 @@ -1166,8 +1166,8 @@ suite "Replication": test "Add and connect replicas": var rm = newReplicationManager(rmAsync) - rm.addReplica(newReplica("r1", "10.0.0.1", 5432)) - rm.addReplica(newReplica("r2", "10.0.0.2", 5432)) + rm.addReplica(newReplica("r1", "10.0.0.1", 9472)) + rm.addReplica(newReplica("r2", "10.0.0.2", 9472)) check rm.totalReplicaCount == 2 rm.connectReplica("r1") @@ -1175,7 +1175,7 @@ suite "Replication": test "Async replication — write returns immediately": var rm = newReplicationManager(rmAsync) - rm.addReplica(newReplica("r1", "10.0.0.1", 5432)) + rm.addReplica(newReplica("r1", "10.0.0.1", 9472)) rm.connectReplica("r1") let lsn = rm.writeLsn(@[1'u8, 2, 3]) @@ -1185,7 +1185,7 @@ suite "Replication": test "Sync replication — wait for ack": var rm = newReplicationManager(rmSync) - rm.addReplica(newReplica("r1", "10.0.0.1", 5432)) + rm.addReplica(newReplica("r1", "10.0.0.1", 9472)) rm.connectReplica("r1") let lsn = rm.writeLsn(@[1'u8, 2, 3]) @@ -1196,9 +1196,9 @@ suite "Replication": test "Semi-sync replication": var rm = newReplicationManager(rmSemiSync, syncCount = 2) - rm.addReplica(newReplica("r1", "10.0.0.1", 5432)) - rm.addReplica(newReplica("r2", "10.0.0.2", 5432)) - rm.addReplica(newReplica("r3", "10.0.0.3", 5432)) + rm.addReplica(newReplica("r1", "10.0.0.1", 9472)) + rm.addReplica(newReplica("r2", "10.0.0.2", 9472)) + rm.addReplica(newReplica("r3", "10.0.0.3", 9472)) rm.connectReplica("r1") rm.connectReplica("r2") rm.connectReplica("r3") @@ -1214,7 +1214,7 @@ suite "Replication": test "Replica status": var rm = newReplicationManager(rmAsync) - rm.addReplica(newReplica("r1", "10.0.0.1", 5432)) + rm.addReplica(newReplica("r1", "10.0.0.1", 9472)) rm.connectReplica("r1") let status = rm.replicaStatus() check status.len == 1 @@ -1454,16 +1454,16 @@ suite "Gossip Protocol": suite "Client Library": test "Connection string parser": - let config = parseConnectionString("host=localhost port=5432 dbname=test user=admin") + let config = parseConnectionString("host=localhost port=9472 dbname=test user=admin") check config.host == "localhost" - check config.port == 5432 + check config.port == 9472 check config.database == "test" check config.username == "admin" test "Client config defaults": let config = defaultClientConfig() check config.host == "127.0.0.1" - check config.port == 5432 + check config.port == 9472 test "Query builder": let client = newBaraClient() @@ -1658,13 +1658,13 @@ suite "Adaptive Query Execution": suite "Distributed Transactions": test "Create distributed transaction": var txn = newDistributedTransaction("coordinator") - txn.addParticipant("node1", "10.0.0.1", 5432) - txn.addParticipant("node2", "10.0.0.2", 5432) + txn.addParticipant("node1", "10.0.0.1", 9472) + txn.addParticipant("node2", "10.0.0.2", 9472) check txn.participantCount == 2 test "Two-phase commit flow": var txn = newDistributedTransaction("coordinator") - txn.addParticipant("n1", "10.0.0.1", 5432) + txn.addParticipant("n1", "10.0.0.1", 9472) check txn.prepare() check txn.state() == dtsPrepared check txn.commit() @@ -1672,7 +1672,7 @@ suite "Distributed Transactions": test "Rollback dist transaction": var txn = newDistributedTransaction("coordinator") - txn.addParticipant("n1", "10.0.0.1", 5432) + txn.addParticipant("n1", "10.0.0.1", 9472) check txn.rollback() check txn.isAborted @@ -1680,7 +1680,7 @@ suite "Distributed Transactions": var tm = newDistTxnManager() let txn = tm.beginTransaction("node1") check tm.activeCount == 1 - txn.addParticipant("n2", "10.0.0.2", 5432) + txn.addParticipant("n2", "10.0.0.2", 9472) check txn.prepare() check txn.commit() tm.cleanupCompleted()