pub struct StorageSynchronizer<T, R> {
pub turso: Arc<T>,
pub redb: Arc<R>,
/* private fields */
}Expand description
Storage synchronizer for coordinating Turso and redb
Fields§
§turso: Arc<T>Source storage (typically Turso - durable)
redb: Arc<R>Cache storage (typically redb - fast)
Implementations§
Source§impl<T, R> StorageSynchronizer<T, R>
impl<T, R> StorageSynchronizer<T, R>
Source§impl<T, R> StorageSynchronizer<T, R>where
T: StorageBackend + 'static,
R: StorageBackend + 'static,
impl<T, R> StorageSynchronizer<T, R>where
T: StorageBackend + 'static,
R: StorageBackend + 'static,
Sourcepub async fn sync_episode_to_cache(&self, episode_id: Uuid) -> Result<()>
pub async fn sync_episode_to_cache(&self, episode_id: Uuid) -> Result<()>
Sourcepub async fn sync_all_recent_episodes(
&self,
since: DateTime<Utc>,
) -> Result<SyncStats>
pub async fn sync_all_recent_episodes( &self, since: DateTime<Utc>, ) -> Result<SyncStats>
Sync all episodes modified since a given timestamp
Queries the source storage for recent episodes and syncs them to the cache.
§Arguments
since- Only sync episodes withstart_time>= this timestamp
§Returns
Statistics about the sync operation (episodes synced, errors)
§Errors
Returns error if query fails, but continues syncing other episodes if individual stores fail
Sourcepub fn start_periodic_sync(
self: Arc<Self>,
interval: Duration,
) -> JoinHandle<()>
pub fn start_periodic_sync( self: Arc<Self>, interval: Duration, ) -> JoinHandle<()>
Start a periodic background sync task
Spawns a background task that syncs recent episodes at the specified interval.
The task will continue running until the returned JoinHandle is dropped or aborted.
§Arguments
interval- How often to run the sync
§Returns
JoinHandle that can be used to cancel the background task
§Example
ⓘ
use std::time::Duration;
use std::sync::Arc;
let sync = Arc::new(StorageSynchronizer::new(turso, redb));
let handle = sync.start_periodic_sync(Duration::from_secs(300));
// Later, to stop the sync:
handle.abort();Auto Trait Implementations§
impl<T, R> Freeze for StorageSynchronizer<T, R>
impl<T, R> !RefUnwindSafe for StorageSynchronizer<T, R>
impl<T, R> Send for StorageSynchronizer<T, R>
impl<T, R> Sync for StorageSynchronizer<T, R>
impl<T, R> Unpin for StorageSynchronizer<T, R>
impl<T, R> UnsafeUnpin for StorageSynchronizer<T, R>
impl<T, R> !UnwindSafe for StorageSynchronizer<T, R>
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.