Skip to main content

Crate noxu_engine

Crate noxu_engine 

Source
Expand description

Internal component of the noxu database.

This crate is published only so the noxu umbrella crate can depend on it. Use noxu (noxu = "3") in applications; depend on this crate directly only if you are extending the engine internals. Its API may change without a major version bump.

Engine orchestration for Noxu DB.

Wires together all internal subsystems, manages daemon thread lifecycle, and coordinates environment open/close.

§Overview

The noxu-engine crate is the internal orchestration layer for Noxu DB. It brings together all the subsystems built in earlier phases:

  • noxu-dbi: EnvironmentImpl, DatabaseImpl, CursorImpl
  • noxu-txn: Transaction and lock management
  • noxu-evictor: Cache eviction
  • noxu-cleaner: Log garbage collection
  • noxu-recovery: Checkpointing and recovery

§Architecture

The Engine struct is the central coordination point. It:

  1. Creates and owns all subsystems
  2. Runs recovery on environment open
  3. Starts background daemon threads (evictor, cleaner, checkpointer)
  4. Coordinates orderly shutdown
  5. Provides unified access to all subsystems

§Usage

use noxu_engine::{Engine, EngineConfig};

// Open an environment
let config = EngineConfig::new("/data/mydb")
    .cache_size(128 * 1024 * 1024)
    .transactional(true);
let engine = Engine::open(config)?;

// Use the engine...
let stats = engine.get_stats();
println!("Cache usage: {:.1}%", stats.cache_utilization_percent());

// Explicitly close (or drop will close)
engine.close()?;

§Configuration

Environment behavior is controlled via EngineConfig:

  • Cache size and eviction settings
  • Transaction and lock timeouts
  • Daemon thread intervals
  • Read-only mode
  • Checkpoint and cleaning thresholds

§Background Daemons

Three daemon threads run in the background:

  1. Evictor: Evicts nodes from cache when memory budget is exceeded
  2. Cleaner: Garbage collects log files when utilization is low
  3. Checkpointer: Flushes dirty nodes to bound recovery time

All daemons can be individually enabled/disabled via configuration.

§Statistics

EnvironmentStats provides a unified view of all subsystem statistics:

  • Cache usage and eviction metrics
  • Cleaning progress and file statistics
  • Checkpoint frequency and flush counts
  • Database and transaction counts

Re-exports§

pub use daemon_manager::DaemonManager;
pub use engine::Engine;
pub use engine_config::EngineConfig;
pub use env_stats::EnvironmentStats;
pub use error::EngineError;
pub use error::Result;
pub use verify::VerifyConfig;
pub use verify::VerifyError;
pub use verify::VerifyResult;
pub use verify::verify_database;
pub use verify::verify_database_impl;
pub use verify::verify_environment;
pub use verify::verify_tree;

Modules§

daemon_manager
Background daemon lifecycle management.
engine
Main engine implementation for Noxu DB.
engine_config
Configuration for the Noxu DB engine.
env_stats
Aggregated environment statistics.
error
Error types for the Noxu DB engine.
verify
Environment verification utilities.