pub struct RetentionConfig {
pub default_days: u32,
pub namespace_days: HashMap<Namespace, u32>,
pub minimum_days: u32,
pub batch_limit: usize,
}Expand description
Retention policy configuration.
Supports a default retention period and per-namespace overrides.
Fields§
§default_days: u32Default retention period in days.
namespace_days: HashMap<Namespace, u32>Per-namespace retention overrides.
Namespaces not in this map use default_days.
minimum_days: u32Minimum retention period in days (cannot go below this).
Provides a safety floor to prevent accidental data loss.
batch_limit: usizeMaximum memories to process in a single GC run.
Prevents long-running GC operations.
Implementations§
Source§impl RetentionConfig
impl RetentionConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Creates a retention config from environment variables.
Reads:
SUBCOG_RETENTION_DAYS: Default retention periodSUBCOG_RETENTION_MIN_DAYS: Minimum retention periodSUBCOG_RETENTION_BATCH_LIMIT: Batch limit for GC runsSUBCOG_RETENTION_<NAMESPACE>_DAYS: Per-namespace overrides
Sourcepub const fn with_default_days(self, days: u32) -> Self
pub const fn with_default_days(self, days: u32) -> Self
Sets the default retention period.
Sourcepub const fn with_minimum_days(self, days: u32) -> Self
pub const fn with_minimum_days(self, days: u32) -> Self
Sets the minimum retention period.
Sourcepub const fn with_batch_limit(self, limit: usize) -> Self
pub const fn with_batch_limit(self, limit: usize) -> Self
Sets the batch limit.
Sourcepub fn with_namespace_days(self, namespace: Namespace, days: u32) -> Self
pub fn with_namespace_days(self, namespace: Namespace, days: u32) -> Self
Sets a per-namespace retention override.
Sourcepub fn effective_days(&self, namespace: Namespace) -> u32
pub fn effective_days(&self, namespace: Namespace) -> u32
Gets the effective retention period for a namespace.
Returns the namespace-specific override if set, otherwise the default.
The result is clamped to be at least minimum_days.
Sourcepub fn cutoff_timestamp(&self, namespace: Namespace) -> u64
pub fn cutoff_timestamp(&self, namespace: Namespace) -> u64
Returns the cutoff timestamp for expired memories in a namespace.
Memories with created_at before this timestamp are considered expired.
Trait Implementations§
Source§impl Clone for RetentionConfig
impl Clone for RetentionConfig
Source§fn clone(&self) -> RetentionConfig
fn clone(&self) -> RetentionConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RetentionConfig
impl Debug for RetentionConfig
Auto Trait Implementations§
impl Freeze for RetentionConfig
impl RefUnwindSafe for RetentionConfig
impl Send for RetentionConfig
impl Sync for RetentionConfig
impl Unpin for RetentionConfig
impl UnwindSafe for RetentionConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
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>,
Layered].