pub struct WalWriter { /* private fields */ }Expand description
Appends LogEntry values to a segment-based WAL on disk.
Segment files are named wal-{segment_id:08}.seg inside the configured
directory. When the current segment exceeds
max_segment_size a new segment is
created automatically.
Implementations§
Source§impl WalWriter
impl WalWriter
Sourcepub fn new(
dir: &Path,
sync_mode: SyncMode,
max_segment_size: u64,
) -> RaftResult<Self>
pub fn new( dir: &Path, sync_mode: SyncMode, max_segment_size: u64, ) -> RaftResult<Self>
Create a new writer rooted at dir.
The directory is created if it does not exist. Any existing segments are discovered so that new writes continue from the latest segment.
Sourcepub fn append(&mut self, entry: &LogEntry) -> RaftResult<()>
pub fn append(&mut self, entry: &LogEntry) -> RaftResult<()>
Append a single log entry to the WAL.
Rotates to a new segment when the current one exceeds the configured
maximum size. Calls fsync according to the configured
SyncMode.
Sourcepub fn sync(&mut self) -> RaftResult<()>
pub fn sync(&mut self) -> RaftResult<()>
Force an fsync on the current segment, regardless of SyncMode.
Sourcepub fn truncate_from(&mut self, from_index: LogIndex) -> RaftResult<()>
pub fn truncate_from(&mut self, from_index: LogIndex) -> RaftResult<()>
Truncate all entries with index >= from_index.
This rewrites segment files, removing entries at or beyond the given index. After truncation the writer re-opens the last remaining segment (or creates a fresh one if all entries were removed).
Auto Trait Implementations§
impl Freeze for WalWriter
impl RefUnwindSafe for WalWriter
impl Send for WalWriter
impl Sync for WalWriter
impl Unpin for WalWriter
impl UnsafeUnpin for WalWriter
impl UnwindSafe for WalWriter
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.