pub struct Engine { /* private fields */ }Expand description
Per-database query execution engine with concurrency control.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new(
backend: Arc<Backend>,
num_readers: usize,
journal: Option<JournalSender>,
sandbox: Option<SandboxConfig>,
) -> Self
pub fn new( backend: Arc<Backend>, num_readers: usize, journal: Option<JournalSender>, sandbox: Option<SandboxConfig>, ) -> Self
Create a new Engine wrapping the given backend.
num_readers: max concurrent read queries (semaphore permits)journal: optional journal sender for write-ahead loggingsandbox: optional statement-level sandbox for multi-tenant safety
Sourcepub async fn execute(
&self,
query: String,
params: Option<Value>,
) -> Result<ExecutedQuery, GraphdError>
pub async fn execute( &self, query: String, params: Option<Value>, ) -> Result<ExecutedQuery, GraphdError>
Execute an auto-commit query, routing reads vs writes automatically.
- Reads: bounded by semaphore (up to N concurrent).
- Writes: serialized by mutex (1 at a time), auto-journaled on success.
If a sandbox is configured, queries are checked before execution.
Sourcepub fn connection(&self) -> Result<Connection<'_>, GraphdError>
pub fn connection(&self) -> Result<Connection<'_>, GraphdError>
Create a dedicated connection for Bolt sessions and HTTP transactions. The caller owns the connection for its lifetime.
Sourcepub fn snapshot_lock(&self) -> &Arc<RwLock<()>> ⓘ
pub fn snapshot_lock(&self) -> &Arc<RwLock<()>> ⓘ
Snapshot lock — take a read lock for queries, write lock for CHECKPOINT.
Sourcepub fn journal(&self) -> &Option<JournalSender>
pub fn journal(&self) -> &Option<JournalSender>
Journal sender (None if journaling is disabled).
Sourcepub fn backend(&self) -> &Arc<Backend> ⓘ
pub fn backend(&self) -> &Arc<Backend> ⓘ
Underlying backend (for snapshot creation and restore paths).
Sourcepub fn sandbox(&self) -> Option<&Arc<SandboxConfig>>
pub fn sandbox(&self) -> Option<&Arc<SandboxConfig>>
Sandbox config (for manual query checks in Bolt transaction mode).
Sourcepub fn acquire_writer(&self) -> MutexGuard<'_, ()>
pub fn acquire_writer(&self) -> MutexGuard<'_, ()>
Acquire exclusive write access (blocking).
Use from spawn_blocking contexts (Bolt sessions, HTTP transaction workers).
For async contexts, use execute() which acquires the lock internally.
Hold the guard for the duration of a write transaction (BEGIN→COMMIT), or for a single auto-commit mutation.