pub struct SqliteReplicator { /* private fields */ }Expand description
SQLite WAL-based replicator to S3
Monitors a SQLite database’s WAL file and replicates changes to S3 for
persistence and disaster recovery.
Implementations§
Source§impl SqliteReplicator
impl SqliteReplicator
Sourcepub async fn new(
config: SqliteReplicatorConfig,
s3_config: &LayerStorageConfig,
) -> Result<Self>
pub async fn new( config: SqliteReplicatorConfig, s3_config: &LayerStorageConfig, ) -> Result<Self>
Sourcepub async fn start(&self) -> Result<()>
pub async fn start(&self) -> Result<()>
Start the replicator background tasks
This spawns background tasks for:
- WAL file monitoring and change detection
- Cache upload worker (handles retries)
- Periodic snapshot creation
§Errors
Returns an error if the WAL monitor cannot be started (e.g., database file doesn’t exist).
Sourcepub async fn flush(&self) -> Result<()>
pub async fn flush(&self) -> Result<()>
Force flush all pending changes to S3
Call this before shutdown to ensure all changes are persisted. This will:
- Create a final snapshot
- Upload all pending cache entries
- Wait for uploads to complete
§Errors
Returns an error if the final snapshot or upload fails.
Sourcepub async fn restore(&self) -> Result<bool>
pub async fn restore(&self) -> Result<bool>
Restore database from S3
Downloads the latest snapshot and any subsequent WAL segments from S3, then applies them to reconstruct the database.
§Returns
Ok(true)if a backup was found and restoredOk(false)if no backup was found in S3Err(_)if restore failed
§Errors
Returns an error if downloading the snapshot or WAL segments fails, or if applying them to reconstruct the database fails.
Sourcepub fn status(&self) -> ReplicationStatus
pub fn status(&self) -> ReplicationStatus
Get current replication status
Auto Trait Implementations§
impl Freeze for SqliteReplicator
impl !RefUnwindSafe for SqliteReplicator
impl Send for SqliteReplicator
impl Sync for SqliteReplicator
impl Unpin for SqliteReplicator
impl UnsafeUnpin for SqliteReplicator
impl !UnwindSafe for SqliteReplicator
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
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 more