pub struct RetentionPolicyEngine {
pub config: PolicyConfig,
pub stats: RetentionEngineStats,
}Expand description
Engine that evaluates block retention decisions against a PolicyConfig.
Fields§
§config: PolicyConfigPolicy configuration driving all evaluations.
stats: RetentionEngineStatsRunning statistics since the last reset_stats().
Implementations§
Source§impl RetentionPolicyEngine
impl RetentionPolicyEngine
Sourcepub fn new(config: PolicyConfig) -> Self
pub fn new(config: PolicyConfig) -> Self
Create a new engine with the given configuration.
Sourcepub fn evaluate(
&mut self,
record: &BlockRecord,
now_secs: u64,
) -> RetentionDecision
pub fn evaluate( &mut self, record: &BlockRecord, now_secs: u64, ) -> RetentionDecision
Evaluate the retention decision for a single BlockRecord.
Rules are evaluated in order; the first matching rule wins.
If no rule matches, config.default_decision is returned.
Statistics are updated after every call.
Sourcepub fn evaluate_batch(
&mut self,
records: &[BlockRecord],
now_secs: u64,
) -> Vec<(String, RetentionDecision)>
pub fn evaluate_batch( &mut self, records: &[BlockRecord], now_secs: u64, ) -> Vec<(String, RetentionDecision)>
Evaluate all records in records and return (cid, decision) pairs.
Sourcepub fn blocks_to_expire<'a>(
&mut self,
records: &'a [BlockRecord],
now_secs: u64,
) -> Vec<&'a BlockRecord>
pub fn blocks_to_expire<'a>( &mut self, records: &'a [BlockRecord], now_secs: u64, ) -> Vec<&'a BlockRecord>
Return references to all blocks that should be expired.
Sourcepub fn stats(&self) -> &RetentionEngineStats
pub fn stats(&self) -> &RetentionEngineStats
Return a reference to the current statistics.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset all statistics counters to zero.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RetentionPolicyEngine
impl RefUnwindSafe for RetentionPolicyEngine
impl Send for RetentionPolicyEngine
impl Sync for RetentionPolicyEngine
impl Unpin for RetentionPolicyEngine
impl UnsafeUnpin for RetentionPolicyEngine
impl UnwindSafe for RetentionPolicyEngine
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
Mutably borrows from an owned value. Read more
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>
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