chore: change default ports to non-standard ones (9472, 9470, 9471)

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