36 lines
1.2 KiB
Rust
36 lines
1.2 KiB
Rust
|
|
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,
|
||
|
|
}
|