armdb 0.1.13

sharded bitcask key-value storage optimized for NVMe
Documentation
//! Trait abstracting the leader engine for the replication server.
//! Lets tests mock engine behavior and keeps server code decoupled
//! from `FixedEngine`.

use std::sync::Arc;

use crate::error::DbResult;
use crate::fixed_replication::event::FixedReplicationEvent;

pub trait FixedEngineAccess: Send + Sync + 'static {
    fn shard_count(&self) -> usize;
    fn key_len(&self) -> usize;
    fn value_len(&self) -> usize;
    fn slot_size(&self) -> u16;
    fn current_slot_count(&self, shard_id: usize) -> u32;
    fn shard_prefix_bits(&self) -> u8;

    /// Read a contiguous chunk of `count` slots starting at `start_slot`
    /// into a fresh Vec<u8>. Byte length = `count * slot_size`.
    fn read_shard_chunk(&self, shard_id: usize, start_slot: u32, count: usize)
    -> DbResult<Vec<u8>>;

    /// Install SPSC producers into shards (lazy on first follower).
    fn install_replication_producers(&self, producers: Vec<rtrb::Producer<FixedReplicationEvent>>);

    /// Hint for monitoring — follower Acked this version. Used only for metrics.
    fn update_min_replicated_version(&self, shard_id: usize, version: u32);
}

/// Convenience alias used across server threads.
pub type ArcEngine = Arc<dyn FixedEngineAccess>;