Skip to main content

Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }
Expand description

Per-database query execution engine with concurrency control.

Implementations§

Source§

impl Engine

Source

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 logging
  • sandbox: optional statement-level sandbox for multi-tenant safety
Source

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.

Source

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.

Source

pub fn snapshot_lock(&self) -> &Arc<RwLock<()>> ⓘ

Snapshot lock — take a read lock for queries, write lock for CHECKPOINT.

Source

pub fn journal(&self) -> &Option<JournalSender>

Journal sender (None if journaling is disabled).

Source

pub fn backend(&self) -> &Arc<Backend> ⓘ

Underlying backend (for snapshot creation and restore paths).

Source

pub fn sandbox(&self) -> Option<&Arc<SandboxConfig>>

Sandbox config (for manual query checks in Bolt transaction mode).

Source

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.

Auto Trait Implementations§

§

impl !Freeze for Engine

§

impl !RefUnwindSafe for Engine

§

impl !UnwindSafe for Engine

§

impl Forget for Engine

§

impl Move for Engine

§

impl Send for Engine

§

impl Sync for Engine

§

impl Unpin for Engine

§

impl UnsafeUnpin for Engine

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more