pub struct TtlManager { /* private fields */ }Expand description
TTL Manager for automatic document expiration
Tracks document expiry times and runs background cleanup task to remove expired documents from the store.
Implementations§
Source§impl TtlManager
impl TtlManager
Sourcepub fn new(store: Arc<AutomergeStore>, config: TtlConfig) -> TtlManager
pub fn new(store: Arc<AutomergeStore>, config: TtlConfig) -> TtlManager
Create a new TTL Manager
§Arguments
store- AutomergeStore for document deletionconfig- TTL configuration (beacon_ttl, position_ttl, etc.)
§Example
let store = AutomergeStore::new(iroh_transport.clone());
let config = TtlConfig::tactical(); // 30s beacon TTL
let ttl_manager = TtlManager::new(store, config);Sourcepub fn cleanup_expired(&self) -> Result<usize, Error>
pub fn cleanup_expired(&self) -> Result<usize, Error>
Remove all expired documents
This method is called by the background cleanup task every 10 seconds. It finds all documents with expiry times <= now and deletes them. Documents are ordered according to the configured eviction strategy (OldestFirst, KeepLastN, etc.) before deletion.
§Returns
Number of documents cleaned up
Sourcepub fn extend_ttls_for_offline(&self)
pub fn extend_ttls_for_offline(&self)
Extend TTLs for all pending documents when the node is offline
When no peers are connected, this extends remaining TTLs by the configured offline retention multiplier (offline_ttl / online_ttl ratio). This prevents premature eviction of data that can’t be re-synced.
Should be called periodically from the sync loop when connected_peers() is empty.
Sourcepub fn start_background_cleanup(&self)
pub fn start_background_cleanup(&self)
Sourcepub fn stop_background_cleanup(&self)
pub fn stop_background_cleanup(&self)
Stop background cleanup task
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Get count of documents scheduled for expiration
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TtlManager
impl !RefUnwindSafe for TtlManager
impl Send for TtlManager
impl Sync for TtlManager
impl Unpin for TtlManager
impl UnsafeUnpin for TtlManager
impl !UnwindSafe for TtlManager
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