-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
Configuration defaults use magic numbers with inconsistent formatting and no named constants.
Location
crates/raft-store/src/config.rs:182-216
impl Default for RaftConfig {
fn default() -> Self {
Self {
log_cache_max_items: 1_000_000,
log_cache_capacity: 1024 * 1024 * 1024, // 1GB - expression
log_wal_chunk_max_records: 100_000,
log_wal_chunk_max_size: 256 * 1024 * 1024, // 256MB - expression
snapshot_chunk_size: 4194304, // 4MB - raw number
snapshot_db_block_cache_size: 1073741824, // 1GB - raw number
// ...
}
}
}Problem
- Inconsistent formats: some use
1024 * 1024 * 1024, others use1073741824 - Some have comments explaining units, others do not
- No named constants - hard to understand intent
- Difficult to tune or document configuration options
Suggested Fix
Define named constants:
// In a constants module
const KB: u64 = 1024;
const MB: u64 = 1024 * KB;
const GB: u64 = 1024 * MB;
const DEFAULT_LOG_CACHE_MAX_ITEMS: u64 = 1_000_000;
const DEFAULT_LOG_CACHE_CAPACITY: u64 = 1 * GB;
const DEFAULT_WAL_CHUNK_MAX_RECORDS: u64 = 100_000;
const DEFAULT_WAL_CHUNK_MAX_SIZE: u64 = 256 * MB;
const DEFAULT_SNAPSHOT_CHUNK_SIZE: u64 = 4 * MB;
const DEFAULT_BLOCK_CACHE_SIZE: u64 = 1 * GB;
impl Default for RaftConfig {
fn default() -> Self {
Self {
log_cache_max_items: DEFAULT_LOG_CACHE_MAX_ITEMS,
log_cache_capacity: DEFAULT_LOG_CACHE_CAPACITY,
// ...
}
}
}Priority
P2 - Code maintainability
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request