-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: bsbds <69835502+bsbds@users.noreply.github.com> refactor: wal storage Signed-off-by: bsbds <69835502+bsbds@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
569 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::path::{Path, PathBuf}; | ||
|
||
/// Size in bytes per segment, default is 64MiB | ||
const DEFAULT_SEGMENT_SIZE: u64 = 64 * 1024 * 1024; | ||
|
||
/// The config for WAL | ||
#[derive(Debug, Clone)] | ||
pub(crate) struct WALConfig { | ||
/// The path of this config | ||
pub(super) dir: PathBuf, | ||
/// The maximum size of this segment | ||
/// | ||
/// NOTE: This is a soft limit, the actual size may larger than this | ||
pub(super) max_segment_size: u64, | ||
} | ||
|
||
impl WALConfig { | ||
/// Creates a new `WALConfig` | ||
pub(crate) fn new(dir: impl AsRef<Path>) -> Self { | ||
Self { | ||
dir: dir.as_ref().into(), | ||
max_segment_size: DEFAULT_SEGMENT_SIZE, | ||
} | ||
} | ||
|
||
/// Sets the `max_segment_size` | ||
pub(crate) fn with_max_segment_size(self, size: u64) -> Self { | ||
Self { | ||
dir: self.dir, | ||
max_segment_size: size, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.