pub struct DispositionStore { /* private fields */ }Expand description
The rolling per-rule disposition store.
Updated only by the ingestion paths (it never sits in the eval or sink path), so it is strictly additive and cannot affect detection throughput.
Implementations§
Source§impl DispositionStore
impl DispositionStore
Sourcepub fn new(config: DispositionConfig) -> Self
pub fn new(config: DispositionConfig) -> Self
Create an empty store with the given config.
Sourcepub fn config(&self) -> &DispositionConfig
pub fn config(&self) -> &DispositionConfig
The store’s configuration.
Sourcepub fn apply(&mut self, disposition: &Disposition, now: i64) -> IngestOutcome
pub fn apply(&mut self, disposition: &Disposition, now: i64) -> IngestOutcome
Apply one disposition at now (epoch seconds), enforcing idempotency.
Returns IngestOutcome::Rejected for an unresolved incident-scoped
record (no rule_id), IngestOutcome::Duplicate for a redelivery, and
IngestOutcome::Accepted otherwise. The affected rule’s bucket map is
pruned to the window on each apply.
Sourcepub fn prune(&mut self, now: i64)
pub fn prune(&mut self, now: i64)
Drop buckets older than the window across every rule (called on a periodic tick). Rules left with no buckets are removed.
Sourcepub fn ratio(&self, rule_id: &str) -> Option<f64>
pub fn ratio(&self, rule_id: &str) -> Option<f64>
The false-positive ratio for one rule over the window, or None when it
has fewer than min_sample dispositions.
Sourcepub fn summaries(&self) -> Vec<RuleSummary>
pub fn summaries(&self) -> Vec<RuleSummary>
A per-rule summary for every rule with at least one disposition, sorted
by rule_id for stable output.
Sourcepub fn rule_count(&self) -> usize
pub fn rule_count(&self) -> usize
Number of rules currently tracked.
Sourcepub fn snapshot(&self) -> DispositionSnapshot
pub fn snapshot(&self) -> DispositionSnapshot
Capture the store into a versioned snapshot for persistence.
Sourcepub fn restore(&mut self, snapshot: DispositionSnapshot, now: i64) -> bool
pub fn restore(&mut self, snapshot: DispositionSnapshot, now: i64) -> bool
Restore a snapshot at now, pruning buckets and seen ids past the
window. Returns false on a version mismatch (caller starts fresh).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DispositionStore
impl RefUnwindSafe for DispositionStore
impl Send for DispositionStore
impl Sync for DispositionStore
impl Unpin for DispositionStore
impl UnsafeUnpin for DispositionStore
impl UnwindSafe for DispositionStore
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointerSource§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, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&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