pub struct Config {
pub dir: String,
pub log_cache_max_items: Option<usize>,
pub log_cache_capacity: Option<usize>,
pub read_buffer_size: Option<usize>,
pub chunk_max_records: Option<usize>,
pub chunk_max_size: Option<usize>,
pub truncate_incomplete_record: Option<bool>,
}Expand description
Configuration for Raft-log.
This struct holds various configuration parameters for the Raft-log, including directory location, cache settings, and chunk management options.
Optional parameters are Option<T> in this struct, and default values is
evaluated when a getter method is called.
Fields§
§dir: StringBase directory for storing Raft-log files
log_cache_max_items: Option<usize>Maximum number of items to keep in the log cache
log_cache_capacity: Option<usize>Maximum capacity of the log cache in bytes
read_buffer_size: Option<usize>Size of the read buffer in bytes
chunk_max_records: Option<usize>Maximum number of records in a chunk
chunk_max_size: Option<usize>Maximum size of a chunk in bytes
truncate_incomplete_record: Option<bool>Whether to truncate the last half sync-ed record.
If truncate, the chunk is considered successfully opened. Otherwise, an io::Error will be returned.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(dir: impl ToString) -> Self
pub fn new(dir: impl ToString) -> Self
Creates a new Config with the specified directory and default values for other fields
Sourcepub fn new_full(
dir: impl ToString,
log_cache_max_items: Option<usize>,
log_cache_capacity: Option<usize>,
read_buffer_size: Option<usize>,
chunk_max_records: Option<usize>,
chunk_max_size: Option<usize>,
) -> Self
pub fn new_full( dir: impl ToString, log_cache_max_items: Option<usize>, log_cache_capacity: Option<usize>, read_buffer_size: Option<usize>, chunk_max_records: Option<usize>, chunk_max_size: Option<usize>, ) -> Self
Creates a new Config with all configurable parameters
Sourcepub fn log_cache_max_items(&self) -> usize
pub fn log_cache_max_items(&self) -> usize
Returns the maximum number of items in log cache (defaults to 100,000)
Sourcepub fn log_cache_capacity(&self) -> usize
pub fn log_cache_capacity(&self) -> usize
Returns the maximum capacity of log cache in bytes (defaults to 1GB)
Sourcepub fn read_buffer_size(&self) -> usize
pub fn read_buffer_size(&self) -> usize
Returns the size of read buffer in bytes (defaults to 64MB)
Sourcepub fn chunk_max_records(&self) -> usize
pub fn chunk_max_records(&self) -> usize
Returns the maximum number of records per chunk (defaults to 1M records)
Sourcepub fn chunk_max_size(&self) -> usize
pub fn chunk_max_size(&self) -> usize
Returns the maximum size of a chunk in bytes (defaults to 1GB)
Sourcepub fn truncate_incomplete_record(&self) -> bool
pub fn truncate_incomplete_record(&self) -> bool
Returns whether to truncate incomplete records (defaults to true)
Sourcepub fn chunk_path(&self, chunk_id: ChunkId) -> String
pub fn chunk_path(&self, chunk_id: ChunkId) -> String
Returns the full path for a given chunk ID