pub struct RetentionGarbageCollector<I: IndexBackend> {
index: Arc<I>,
config: RetentionConfig,
}Expand description
Garbage collector for expired memories based on retention policy.
Identifies memories that have exceeded their retention period and marks them as tombstoned. Supports per-namespace retention policies.
§Thread Safety
The garbage collector holds an Arc reference to the index backend,
making it safe to share across threads.
Fields§
§index: Arc<I>Reference to the index backend for querying and updating memories.
config: RetentionConfigRetention policy configuration.
Implementations§
Source§impl<I: IndexBackend> RetentionGarbageCollector<I>
impl<I: IndexBackend> RetentionGarbageCollector<I>
Sourcepub fn new(index: Arc<I>, config: RetentionConfig) -> Self
pub fn new(index: Arc<I>, config: RetentionConfig) -> Self
Creates a new retention garbage collector.
§Arguments
index- Shared reference to the index backend.config- Retention policy configuration.
Sourcepub fn gc_expired_memories(&self, dry_run: bool) -> Result<RetentionGcResult>
pub fn gc_expired_memories(&self, dry_run: bool) -> Result<RetentionGcResult>
Performs garbage collection on expired memories.
This method:
- Iterates through all namespaces
- For each namespace, calculates the retention cutoff
- Queries for memories older than the cutoff
- Tombstones expired memories (unless
dry_run)
§Arguments
dry_run- If true, only report what would be done without making changes
§Returns
A RetentionGcResult containing statistics about the operation.
§Errors
Returns an error if index backend operations fail.
Sourcefn process_namespace(
&self,
namespace: Namespace,
cutoff: u64,
now: u64,
dry_run: bool,
result: &mut RetentionGcResult,
) -> Result<usize>
fn process_namespace( &self, namespace: Namespace, cutoff: u64, now: u64, dry_run: bool, result: &mut RetentionGcResult, ) -> Result<usize>
Processes a single namespace for expired memories.
Sourcepub const fn config(&self) -> &RetentionConfig
pub const fn config(&self) -> &RetentionConfig
Returns the current retention configuration.
Auto Trait Implementations§
impl<I> Freeze for RetentionGarbageCollector<I>
impl<I> RefUnwindSafe for RetentionGarbageCollector<I>where
I: RefUnwindSafe,
impl<I> Send for RetentionGarbageCollector<I>
impl<I> Sync for RetentionGarbageCollector<I>
impl<I> Unpin for RetentionGarbageCollector<I>
impl<I> UnwindSafe for RetentionGarbageCollector<I>where
I: RefUnwindSafe,
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].