pub struct WalConfig { /* private fields */ }Expand description
Tunable parameters for a Wal.
WalConfig is a builder. Construct it with WalConfig::new (or
Default), set the parameters you care about with the with_* methods,
and pass it to Wal::open_with or
Wal::with_store_and_config. The
builder methods take and return self, so they chain.
New parameters are added here as later milestones land (segment size, sync policy, group-commit window). The builder shape means those additions do not break existing call sites.
§Examples
use wal_db::WalConfig;
// Cap records at 1 MiB instead of the 64 MiB default.
let config = WalConfig::new().with_max_record_size(1024 * 1024);
assert_eq!(config.max_record_size(), 1024 * 1024);Implementations§
Source§impl WalConfig
impl WalConfig
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Start from the defaults.
The only default that matters today is a 64 MiB maximum record size.
use wal_db::WalConfig;
let config = WalConfig::new();
assert_eq!(config.max_record_size(), 64 * 1024 * 1024);Sourcepub const fn with_max_record_size(self, bytes: u32) -> Self
pub const fn with_max_record_size(self, bytes: u32) -> Self
Set the largest record the log will accept, in bytes.
Wal::append rejects any record larger than this
with WalError::RecordTooLarge, and
recovery rejects any on-disk length prefix that claims to be larger
before reading the payload. That second use is the security-relevant one:
it bounds the allocation a corrupt or hostile log can request.
use wal_db::WalConfig;
let config = WalConfig::new().with_max_record_size(4096);
assert_eq!(config.max_record_size(), 4096);Sourcepub const fn max_record_size(self) -> u32
pub const fn max_record_size(self) -> u32
The configured maximum record size, in bytes.
Sourcepub const fn with_recovery_policy(self, policy: RecoveryPolicy) -> Self
pub const fn with_recovery_policy(self, policy: RecoveryPolicy) -> Self
Set how iteration reacts to a damaged record.
Defaults to RecoveryPolicy::StopAtFirstError.
use wal_db::{RecoveryPolicy, WalConfig};
let config = WalConfig::new().with_recovery_policy(RecoveryPolicy::SkipBadRecords);
assert_eq!(config.recovery_policy(), RecoveryPolicy::SkipBadRecords);Sourcepub const fn recovery_policy(self) -> RecoveryPolicy
pub const fn recovery_policy(self) -> RecoveryPolicy
The configured recovery policy.