pub struct AsyncWalManager { /* private fields */ }Expand description
Async Write-Ahead Log manager with non-blocking I/O.
This manager provides the same durability guarantees as the sync version but uses tokio’s async I/O for better throughput in async contexts.
Implementations§
Source§impl AsyncWalManager
impl AsyncWalManager
Sourcepub async fn open(dir: impl AsRef<Path>) -> Result<Self>
pub async fn open(dir: impl AsRef<Path>) -> Result<Self>
Opens or creates an async WAL in the given directory.
§Errors
Returns an error if the directory cannot be created or accessed.
Sourcepub async fn with_config(
dir: impl AsRef<Path>,
config: WalConfig,
) -> Result<Self>
pub async fn with_config( dir: impl AsRef<Path>, config: WalConfig, ) -> Result<Self>
Opens or creates an async WAL with custom configuration.
§Errors
Returns an error if the directory cannot be created or accessed.
Sourcepub async fn checkpoint(&self, current_tx: TxId, epoch: EpochId) -> Result<()>
pub async fn checkpoint(&self, current_tx: TxId, epoch: EpochId) -> Result<()>
Writes a checkpoint marker and returns the checkpoint info.
§Errors
Returns an error if the checkpoint cannot be written.
Sourcepub async fn start_background_sync(&self) -> bool
pub async fn start_background_sync(&self) -> bool
Starts a background sync task for batch durability mode.
The task will periodically sync the WAL based on the batch configuration. This is useful when you want automatic syncing without waiting for individual log calls to trigger it.
§Returns
Returns true if a new background task was started, false if batch
mode is not configured or a task is already running.
Sourcepub async fn stop_background_sync(&self)
pub async fn stop_background_sync(&self)
Stops the background sync task if running.
Sourcepub fn record_count(&self) -> u64
pub fn record_count(&self) -> u64
Returns the total number of records written.
Sourcepub fn durability_mode(&self) -> DurabilityMode
pub fn durability_mode(&self) -> DurabilityMode
Returns the current durability mode.
Sourcepub async fn log_files(&self) -> Result<Vec<PathBuf>>
pub async fn log_files(&self) -> Result<Vec<PathBuf>>
Returns all WAL log file paths in sequence order.
Sourcepub async fn checkpoint_epoch(&self) -> Option<EpochId>
pub async fn checkpoint_epoch(&self) -> Option<EpochId>
Returns the latest checkpoint epoch, if any.