Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub dir: String,
    pub read_buffer_size: Option<usize>,
    pub chunk_max_records: Option<usize>,
    pub chunk_max_size: Option<usize>,
    pub truncate_incomplete_record: Option<bool>,
    pub flush_batch_wait: Option<Duration>,
    pub flush_batch_max_items: Option<usize>,
}
Expand description

Configuration for chunked WAL.

This struct holds directory, chunk, recovery, and flush batching settings.

Optional parameters are Option<T> in this struct, and default values is evaluated when a getter method is called.

Fields§

§dir: String

Base directory for storing WAL files.

§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.

§flush_batch_wait: Option<Duration>

Maximum time the flush worker waits for more write requests before starting a sync batch.

Defaults to 1 millisecond.

§flush_batch_max_items: Option<usize>

Maximum number of write requests to include in one flush batch.

Defaults to 2048. Values smaller than 1 are treated as 1.

Implementations§

Source§

impl Config

Source

pub fn new(dir: impl ToString) -> Self

Creates a new Config with the specified directory and defaults.

Source

pub fn new_full( dir: impl ToString, read_buffer_size: Option<usize>, chunk_max_records: Option<usize>, chunk_max_size: Option<usize>, ) -> Self

Creates a new Config with all configurable parameters

Source

pub fn read_buffer_size(&self) -> usize

Returns the size of read buffer in bytes (defaults to 64MB)

Source

pub fn chunk_max_records(&self) -> usize

Returns the maximum number of records per chunk (defaults to 1M records)

Source

pub fn chunk_max_size(&self) -> usize

Returns the maximum size of a chunk in bytes (defaults to 1GB)

Source

pub fn truncate_incomplete_record(&self) -> bool

Returns whether to truncate incomplete records (defaults to true)

Source

pub fn flush_batch_wait(&self) -> Duration

Returns the bounded wait before syncing a flush batch.

Source

pub fn flush_batch_max_items(&self) -> usize

Returns the maximum number of write requests in one flush batch.

Source

pub fn chunk_path(&self, chunk_id: ChunkId) -> String

Returns the full path for a given chunk ID

Source

pub fn chunk_file_name(chunk_id: ChunkId) -> String

Generates the file name for a given chunk ID

The file name format is “r-{padded_chunk_id}.wal”

Source

pub fn parse_chunk_file_name( file_name: &str, ) -> Result<u64, InvalidChunkFileName>

Parses a chunk file name and returns the chunk ID

§Arguments
  • file_name - Name of the chunk file (format: “r-{padded_chunk_id}.wal”)
§Returns
  • Ok(u64) - The chunk ID if parsing succeeds
  • Err(InvalidChunkFileName) - If the file name format is invalid

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.