BREAKING CHANGE(core): replace the TypeScript database engine with a Rust-backed embedded server and bridge
This commit is contained in:
35
rust/crates/rustdb-commands/src/context.rs
Normal file
35
rust/crates/rustdb-commands/src/context.rs
Normal 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,
|
||||
}
|
||||
Reference in New Issue
Block a user