feat: HTTP server in main entry point + background compaction scheduling
- baradadb.nim now starts both TCP wire protocol and HTTP REST servers - HTTP server runs in background thread via hunos on port TCP+440 - WebSocket server auto-starts on HTTP port + 1 - CompactionManager with background async loop (default 60s interval) - CompactionStrategy wired to LSMTree SSTables - Fixed forward declaration for lowerExpr in executor.nim - 216 tests passing
This commit is contained in:
@@ -8,6 +8,7 @@ import tables
|
||||
import strutils
|
||||
import os
|
||||
import times
|
||||
import std/asyncdispatch
|
||||
import config
|
||||
import ../query/lexer
|
||||
import ../query/parser
|
||||
@@ -22,7 +23,7 @@ type
|
||||
HttpServer* = ref object
|
||||
config: BaraConfig
|
||||
running: bool
|
||||
db: LSMTree
|
||||
db*: LSMTree
|
||||
ctx: ExecutionContext
|
||||
metrics*: Metrics
|
||||
secretKey*: string
|
||||
|
||||
@@ -377,6 +377,8 @@ proc validateType*(colType: string, value: string): (bool, string) =
|
||||
return (false, "Type mismatch: expected " & t & " but got '" & value & "'")
|
||||
return (true, "")
|
||||
|
||||
proc lowerExpr*(node: Node): IRExpr
|
||||
|
||||
proc validateConstraints*(ctx: ExecutionContext, tableName: string,
|
||||
fields: seq[string], values: seq[seq[string]]): (bool, string) =
|
||||
let tbl = ctx.getTableDef(tableName)
|
||||
|
||||
@@ -7,6 +7,7 @@ import std/tables
|
||||
import std/monotimes
|
||||
import std/streams
|
||||
import std/locks
|
||||
import std/asyncdispatch
|
||||
import bloom
|
||||
import wal
|
||||
import mmap
|
||||
@@ -40,15 +41,15 @@ type
|
||||
mmapFile*: MmapFile
|
||||
|
||||
LSMTree* = ref object
|
||||
dir: string
|
||||
dir*: string
|
||||
memTable: MemTable
|
||||
immutableMem: MemTable
|
||||
sstables: seq[SSTable]
|
||||
sstables*: seq[SSTable]
|
||||
wal: WriteAheadLog
|
||||
memMaxSize: int
|
||||
currentSeq: uint64
|
||||
nextSSTableId: int
|
||||
lock: Lock
|
||||
lock*: Lock
|
||||
|
||||
proc newMemTable(maxSize: int = DefaultMemTableSize): MemTable =
|
||||
MemTable(entries: @[], size: 0, maxSize: maxSize)
|
||||
@@ -323,6 +324,7 @@ proc newLSMTree*(dir: string, memMaxSize: int = DefaultMemTableSize): LSMTree =
|
||||
result.memMaxSize = memMaxSize
|
||||
result.currentSeq = 0
|
||||
result.nextSSTableId = nextId
|
||||
discard
|
||||
|
||||
proc put*(db: LSMTree, key: string, value: seq[byte]) =
|
||||
acquire(db.lock)
|
||||
|
||||
Reference in New Issue
Block a user