Skip to main content

Engine

Struct Engine 

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

The Noxu DB engine.

Wires together all internal subsystems:

  • EnvironmentImpl (dbi layer)
  • Evictor (cache management)
  • Cleaner (log GC)
  • Checkpointer (durability)
  • DaemonManager (background threads)

This is the internal engine that noxu-db wraps. It coordinates all subsystems and provides a unified interface for database operations.

Implementations§

Source§

impl Engine

Source

pub fn open(config: EngineConfig) -> Result<Self>

Opens a Noxu DB environment with the given configuration.

This is the main entry point for opening an environment. It:

  1. Validates configuration
  2. Creates the environment directory if needed
  3. Creates EnvironmentImpl (dbi layer)
  4. Creates Evictor, Cleaner, Checkpointer
  5. Runs recovery (RecoveryManager)
  6. Starts daemon threads
  7. Returns the Engine
§Errors

Returns an error if:

  • Configuration is invalid
  • Environment directory cannot be created
  • Recovery fails
  • Any subsystem initialization fails
Source

pub fn close(&self) -> Result<()>

Closes the environment.

Performs orderly shutdown:

  1. Stop daemon threads
  2. Flush final checkpoint
  3. Close EnvironmentImpl

After close(), the Engine cannot be used.

Source

pub fn is_open(&self) -> bool

Returns whether the engine is open.

Source

pub fn get_env_impl(&self) -> &Arc<Mutex<EnvironmentImpl>>

Gets a reference to the EnvironmentImpl.

Source

pub fn get_evictor(&self) -> &Arc<Evictor>

Gets a reference to the Evictor.

Source

pub fn get_cleaner(&self) -> &Arc<Cleaner>

Gets a reference to the Cleaner.

Source

pub fn get_checkpointer(&self) -> &Arc<Checkpointer>

Gets a reference to the Checkpointer.

Source

pub fn get_config(&self) -> &EngineConfig

Gets the engine configuration.

Source

pub fn checkpoint(&self, invoker: &str) -> Result<CheckpointResult>

Performs a checkpoint.

§Arguments
  • invoker - Description of who invoked the checkpoint (for logging)
§Returns

Information about the checkpoint that was performed.

§Errors
Source

pub fn clean(&self, n_files: u32) -> Result<CleanResult>

Performs log cleaning.

§Arguments
  • n_files - Maximum number of files to clean
§Returns

Information about the cleaning operation.

§Errors
Source

pub fn clean_adaptive(&self) -> Result<(CleanResult, u64)>

Throttle-driven cleaning pass for use by the cleaner daemon.

Reads the current log write-byte counter, updates the throttle, then cleans n_files recommended by the throttle.

Returns (CleanResult, sleep_ms) — the daemon should sleep sleep_ms milliseconds before its next pass.

§Errors
Source

pub fn evict(&self) -> Result<EvictResult>

Performs cache eviction.

§Returns

Information about the eviction operation.

§Errors
Source

pub fn get_stats(&self) -> EnvironmentStats

Collects environment statistics.

Returns a snapshot of statistics from all subsystems.

Source

pub fn get_cache_usage(&self) -> u64

Gets the current cache usage in bytes.

Source

pub fn get_cache_budget(&self) -> u64

Gets the cache budget in bytes.

Source

pub fn is_cache_over_budget(&self) -> bool

Checks if the cache is over budget.

Trait Implementations§

Source§

impl Drop for Engine

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Freeze for Engine

§

impl !RefUnwindSafe for Engine

§

impl !UnwindSafe 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, 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.