feat(backend): integrate SurrealDB storage with embedded RocksDB

Add StorageService backed by SurrealDB using the embedded RocksDB provider that persists to ./data (never in memory). Support an optional remote server via SurrealDb:RemoteUrl for frontend sync. Expose readiness and storage probe endpoints under /api/system and add a helper script to start a local SurrealDB server.

Set the backend version to 0.0.1.
This commit is contained in:
Rafał Tyński
2026-10-03 20:23:11 +02:00
parent ac9ce68fbe
commit e8e1658b3a
10 changed files with 265 additions and 1 deletions
+36
View File
@@ -0,0 +1,36 @@
<#
.SYNOPSIS
Uruchamia SurrealDB jako serwer na dedykowanym porcie (tylko dla bazy),
z trwałym magazynem RocksDB w katalogu ./data (nie w pamięci).
.DESCRIPTION
Port (domyślnie 8010) służy wyłącznie SurrealDB i jest używany zarówno przez
backend (HubMi.Api), jak i przez frontend do synchronizacji (WebSocket /rpc).
Dane trwale zapisywane są w backend/data (RocksDB).
#>
param(
[int]$Port = 8010,
[string]$Bind = "127.0.0.1",
[string]$Username = "root",
[string]$Password = "root",
[string]$DataPath = (Join-Path $PSScriptRoot "..\backend\data")
)
$ErrorActionPreference = "Stop"
$surreal = (Get-Command surreal -ErrorAction SilentlyContinue)?.Source
if (-not $surreal) {
throw "Nie znaleziono 'surreal' w PATH. Zainstaluj SurrealDB: https://surrealdb.com/install"
}
$resolvedData = [System.IO.Path]::GetFullPath($DataPath)
New-Item -ItemType Directory -Force -Path $resolvedData | Out-Null
Write-Host "SurrealDB: bind $Bind`:$Port, rocksdb:$resolvedData"
& $surreal start `
--user $Username `
--pass $Password `
--bind "${Bind}:${Port}" `
--log info `
"rocksdb:$resolvedData"