BREAKING CHANGE(core): replace the TypeScript database engine with a Rust-backed embedded server and bridge

This commit is contained in:
2026-03-26 19:48:27 +00:00
parent 8ec2046908
commit e23a951dbe
106 changed files with 11567 additions and 10678 deletions

View File

@@ -0,0 +1,35 @@
use std::sync::Arc;
use bson::Document;
use dashmap::DashMap;
use rustdb_index::IndexEngine;
use rustdb_storage::StorageAdapter;
use rustdb_txn::{SessionEngine, TransactionEngine};
/// Shared command execution context, passed to all handlers.
pub struct CommandContext {
/// The storage backend.
pub storage: Arc<dyn StorageAdapter>,
/// Index engines per namespace: "db.collection" -> IndexEngine.
pub indexes: Arc<DashMap<String, IndexEngine>>,
/// Transaction engine for multi-document transactions.
pub transactions: Arc<TransactionEngine>,
/// Session engine for logical sessions.
pub sessions: Arc<SessionEngine>,
/// Active cursors for getMore / killCursors.
pub cursors: Arc<DashMap<i64, CursorState>>,
/// Server start time (for uptime reporting).
pub start_time: std::time::Instant,
}
/// State of an open cursor from a find or aggregate command.
pub struct CursorState {
/// Documents remaining to be returned.
pub documents: Vec<Document>,
/// Current read position within `documents`.
pub position: usize,
/// Database the cursor belongs to.
pub database: String,
/// Collection the cursor belongs to.
pub collection: String,
}