- M5p1: BM25 text indexing via Tantivy with background syncer (0.26ms @ 10K docs) - M5p2: RRF fusion layer combining BM25 + ANN scores (46µs @ 1K candidates) - M5p3: unified Search query API (8-stage pipeline, BM25 + vector + ranking) - M5p4: creator text + vector indexing and creator search executor (< 20ms @ 200 creators) - Refactor db/mod.rs into focused sub-modules (creators, items, sessions, signals, etc.) - Decompose monolithic files into directory modules (query/executor, ranking/diversity, etc.) - Split brute.rs → brute/mod.rs + brute/tests.rs; extract search executor helpers - Add benches: fusion, search, session, text_index - Add M5 UAT test suites (m5_uat, m5_search, m5p4_creator_search, text_index) - Update blog posts, roadmap, content strategy, and M5 planning docs - Add tmp/ and .claude/worktrees/ to .gitignore Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
80 lines
2.3 KiB
Rust
80 lines
2.3 KiB
Rust
//! WAL configuration.
|
|
//!
|
|
//! Extracted from `mod.rs` to keep the module root focused on the public
|
|
//! handle API (`WalHandle`, `WalSender`, `SignalEvent`).
|
|
|
|
use std::path::PathBuf;
|
|
use std::time::Duration;
|
|
|
|
/// Default segment size: 16 MB.
|
|
const DEFAULT_SEGMENT_SIZE: u64 = 16 * 1024 * 1024;
|
|
|
|
/// Default batch size: up to 100 events per batch.
|
|
const DEFAULT_BATCH_SIZE: usize = 100;
|
|
|
|
/// Default batch timeout: 10 milliseconds.
|
|
const DEFAULT_BATCH_TIMEOUT: Duration = Duration::from_millis(10);
|
|
|
|
/// Default dedup window: 30 seconds (double-buffered, so effective window is ~60s).
|
|
const DEFAULT_DEDUP_WINDOW: Duration = Duration::from_secs(30);
|
|
|
|
/// Configuration for the WAL.
|
|
#[derive(Debug, Clone)]
|
|
pub struct WalConfig {
|
|
/// Base directory for WAL data. Segment files and checkpoint metadata
|
|
/// are stored in `{dir}/wal/`.
|
|
pub dir: PathBuf,
|
|
/// Maximum segment file size in bytes before rotation.
|
|
pub segment_size: u64,
|
|
/// Maximum number of events per batch.
|
|
pub batch_size: usize,
|
|
/// Maximum time to wait before flushing a partial batch.
|
|
pub batch_timeout: Duration,
|
|
/// Duration for the dedup window rotation.
|
|
pub dedup_window: Duration,
|
|
}
|
|
|
|
impl Default for WalConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
dir: PathBuf::from("data"),
|
|
segment_size: DEFAULT_SEGMENT_SIZE,
|
|
batch_size: DEFAULT_BATCH_SIZE,
|
|
batch_timeout: DEFAULT_BATCH_TIMEOUT,
|
|
dedup_window: DEFAULT_DEDUP_WINDOW,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl WalConfig {
|
|
/// The actual WAL directory path: `{self.dir}/wal/`.
|
|
#[must_use]
|
|
pub fn wal_dir(&self) -> PathBuf {
|
|
self.dir.join("wal")
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[allow(clippy::unwrap_used)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn default_config_values() {
|
|
let config = WalConfig::default();
|
|
assert_eq!(config.segment_size, 16 * 1024 * 1024);
|
|
assert_eq!(config.batch_size, 100);
|
|
assert_eq!(config.batch_timeout, Duration::from_millis(10));
|
|
assert_eq!(config.dedup_window, Duration::from_secs(30));
|
|
}
|
|
|
|
#[test]
|
|
fn wal_dir_appends_wal_suffix() {
|
|
let config = WalConfig {
|
|
dir: PathBuf::from("/tmp/mydata"),
|
|
..WalConfig::default()
|
|
};
|
|
assert_eq!(config.wal_dir(), PathBuf::from("/tmp/mydata/wal"));
|
|
}
|
|
}
|