pub struct WriteAheadLog { /* private fields */ }Expand description
Write-ahead log backed by SQLite.
Implementations§
Source§impl WriteAheadLog
impl WriteAheadLog
Sourcepub async fn new(
path: impl AsRef<Path>,
max_items: u64,
) -> Result<Self, StorageError>
pub async fn new( path: impl AsRef<Path>, max_items: u64, ) -> Result<Self, StorageError>
Create a new WAL at the given path.
Sourcepub async fn with_max_bytes(
path: impl AsRef<Path>,
max_items: u64,
max_bytes: u64,
) -> Result<Self, StorageError>
pub async fn with_max_bytes( path: impl AsRef<Path>, max_items: u64, max_bytes: u64, ) -> Result<Self, StorageError>
Create a new WAL with custom max size limit.
Sourcepub async fn write(&self, item: &SyncItem) -> Result<(), StorageError>
pub async fn write(&self, item: &SyncItem) -> Result<(), StorageError>
Write an item to the WAL.
Sourcepub fn file_size_bytes(&self) -> Result<u64>
pub fn file_size_bytes(&self) -> Result<u64>
Get the WAL file size in bytes.
Sourcepub async fn checkpoint(&self) -> Result<(), StorageError>
pub async fn checkpoint(&self) -> Result<(), StorageError>
Run a WAL checkpoint to reclaim disk space. Call this after draining to prevent unbounded file growth.
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Check if WAL has items to drain.
Sourcepub fn under_pressure(&self) -> bool
pub fn under_pressure(&self) -> bool
Check if WAL is under pressure (>= 80% full).
Sourcepub async fn drain_to(
&self,
mysql: &dyn ArchiveStore,
batch_size: usize,
) -> Result<Vec<String>, StorageError>
pub async fn drain_to( &self, mysql: &dyn ArchiveStore, batch_size: usize, ) -> Result<Vec<String>, StorageError>
Drain items from WAL to MySQL using batch operations.
Returns IDs of items successfully drained, or error if MySQL unreachable.
Auto Trait Implementations§
impl !Freeze for WriteAheadLog
impl !RefUnwindSafe for WriteAheadLog
impl Send for WriteAheadLog
impl Sync for WriteAheadLog
impl Unpin for WriteAheadLog
impl !UnwindSafe for WriteAheadLog
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more