pub struct OrphanGarbageCollector { /* private fields */ }Expand description
Lightweight garbage collector that targets orphaned blocks — blocks that are present in the store but are not referenced by any pinned CID.
Unlike the full mark-and-sweep GarbageCollector, this collector does
not traverse DAG links. It simply checks every stored CID against the
caller-supplied pinned_cids set and deletes the rest.
Implementations§
Source§impl OrphanGarbageCollector
impl OrphanGarbageCollector
Sourcepub fn new(config: OrphanGcConfig) -> Self
pub fn new(config: OrphanGcConfig) -> Self
Create a new orphan garbage collector with the given configuration.
Sourcepub async fn collect<S: BlockStore>(
&self,
store: &S,
pinned_cids: &HashSet<String>,
) -> Result<OrphanGcResult>
pub async fn collect<S: BlockStore>( &self, store: &S, pinned_cids: &HashSet<String>, ) -> Result<OrphanGcResult>
Collect orphaned blocks from store.
pinned_cids – the set of CID string representations that must not
be deleted. Every block whose string CID is absent from this set and
is not otherwise protected is treated as an orphan.
When snapshot_registry is supplied, CIDs registered there are also
excluded from collection (they represent HNSW / knowledge-base snapshot
blocks that must outlive their originating sessions).
Sourcepub async fn collect_with_snapshot_registry<S: BlockStore>(
&self,
store: &S,
pinned_cids: &HashSet<String>,
snapshot_registry: Option<&SledSnapshotPinRegistry>,
) -> Result<OrphanGcResult>
pub async fn collect_with_snapshot_registry<S: BlockStore>( &self, store: &S, pinned_cids: &HashSet<String>, snapshot_registry: Option<&SledSnapshotPinRegistry>, ) -> Result<OrphanGcResult>
Variant of collect that additionally consults a
SledSnapshotPinRegistry so that HNSW snapshot CIDs are never GC’d.
Only available when the sled-backend feature is enabled.
Auto Trait Implementations§
impl Freeze for OrphanGarbageCollector
impl RefUnwindSafe for OrphanGarbageCollector
impl Send for OrphanGarbageCollector
impl Sync for OrphanGarbageCollector
impl Unpin for OrphanGarbageCollector
impl UnsafeUnpin for OrphanGarbageCollector
impl UnwindSafe for OrphanGarbageCollector
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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