Struct okaywal::Configuration

source ·
pub struct Configuration<M> {
    pub file_manager: M,
    pub directory: PathId,
    pub preallocate_bytes: u32,
    pub checkpoint_after_bytes: u64,
    pub buffer_bytes: usize,
    pub version_info: Arc<Vec<u8>>,
}
Expand description

A WriteAheadLog configuration.

Fields§

§file_manager: M

The file manager to use for storing data.

Typically this is [StdFileManager].

§directory: PathId

The directory to store the log files in.

§preallocate_bytes: u32

The number of bytes each log file should be preallocated with. Log files may grow to be larger than this size if needed.

§checkpoint_after_bytes: u64

After this many bytes have been written to the active log file, begin a checkpointing process. This number should be less than preallocate_bytes to try to ensure the checkpointing process happens before the preallocated space is fully exhausted. If this amount is too close to the preallocation amount, an entry being written may need to extend the file which is a slow operation.

§buffer_bytes: usize

The number of bytes to use for the in-memory buffer when reading and writing from the log.

§version_info: Arc<Vec<u8>>

An arbitrary chunk of bytes that is stored in the log files. Limited to 255 bytes. This can be used for any purpose, but the design inspiration was to allow detection of what format or version of a format the data was inside of the log without needing to parse the entries.

Implementations§

source§

impl Configuration<StdFileManager>

source

pub fn default_for<P: AsRef<Path>>(path: P) -> Self

Returns the default configuration for a given directory.

This currently is:

  • preallocate_bytes: 1 megabyte
  • checkpoint_after_bytes: 768 kilobytes
  • buffer_bytes: 16 kilobytes
source§

impl<M> Configuration<M>where M: FileManager,

source

pub fn default_with_manager<P: AsRef<Path>>(path: P, file_manager: M) -> Self

Returns the default configuration for a given directory and file manager.

This currently is:

  • preallocate_bytes: 1 megabyte
  • checkpoint_after_bytes: 768 kilobytes
  • buffer_bytes: 16 kilobytes
source

pub fn preallocate_bytes(self, bytes: u32) -> Self

Sets the number of bytes to preallocate for each segment file. Returns self.

Preallocating disk space allows for more consistent performance. This number should be large enough to allow batching multiple entries into one checkpointing operation.

source

pub fn checkpoint_after_bytes(self, bytes: u64) -> Self

Sets the number of bytes written required to begin a checkpoint operation. Returns self.

This value should be smaller than preallocate_bytes to ensure checkpoint operations begin before too much data is written in a log entry. If more data is written before a checkpoint occurs, the segment will grow to accommodate the extra data, but that write will not be as fast due to needing to allocate more space from the filesystem to perform the write.

source

pub fn buffer_bytes(self, bytes: usize) -> Self

Sets the number of bytes to use for internal buffers when reading and writing data to the log. Returns self.

source

pub fn open<Manager: LogManager<M>>( self, manager: Manager ) -> Result<WriteAheadLog<M>>

Opens the log using the provided log manager with this configuration.

Trait Implementations§

source§

impl<M: Clone> Clone for Configuration<M>

source§

fn clone(&self) -> Configuration<M>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<M: Debug> Debug for Configuration<M>

source§

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

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

impl Default for Configuration<StdFileManager>

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<M> RefUnwindSafe for Configuration<M>where M: RefUnwindSafe,

§

impl<M> Send for Configuration<M>where M: Send,

§

impl<M> Sync for Configuration<M>where M: Sync,

§

impl<M> Unpin for Configuration<M>where M: Unpin,

§

impl<M> UnwindSafe for Configuration<M>where M: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.