pub struct RegressionHistoryPolicy { /* private fields */ }Expand description
Adaptive SLO policy backed by per-target blocked-ratio history.
Uses bounded threshold shifts around default class SLOs. History can be persisted to JSON for process restarts and operator inspection.
Implementations§
Source§impl RegressionHistoryPolicy
impl RegressionHistoryPolicy
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create an in-memory adaptive policy with no persistence.
§Example
use stygian_charon::RegressionHistoryPolicy;
let policy = RegressionHistoryPolicy::new();
assert!(policy.tracked_target_count() == 0);Sourcepub fn with_json_store(
path: impl AsRef<Path>,
) -> Result<Self, AdaptivePolicyError>
pub fn with_json_store( path: impl AsRef<Path>, ) -> Result<Self, AdaptivePolicyError>
Create an adaptive policy that persists history to a JSON file.
If the file exists, it is loaded on startup.
§Errors
Returns AdaptivePolicyError when loading the store fails.
§Example
use stygian_charon::RegressionHistoryPolicy;
let _policy = RegressionHistoryPolicy::with_json_store("./charon-history.json")?;Sourcepub fn tracked_target_count(&self) -> usize
pub fn tracked_target_count(&self) -> usize
Number of unique targets tracked by history.
Sourcepub fn observations_for_target(&self, target: &str) -> usize
pub fn observations_for_target(&self, target: &str) -> usize
Number of observations currently retained for one target.
Trait Implementations§
Source§impl AdaptiveSloPolicy for RegressionHistoryPolicy
impl AdaptiveSloPolicy for RegressionHistoryPolicy
Source§fn select_slo(
&self,
target: &str,
target_class: TargetClass,
default: BlockedRatioSlo,
) -> BlockedRatioSlo
fn select_slo( &self, target: &str, target_class: TargetClass, default: BlockedRatioSlo, ) -> BlockedRatioSlo
Select an adjusted SLO for a target using historical observations. Read more
Source§fn record_observation(
&self,
target: &str,
target_class: TargetClass,
blocked_ratio: f64,
escalation_level: RequirementLevel,
) -> Result<(), AdaptivePolicyError>
fn record_observation( &self, target: &str, target_class: TargetClass, blocked_ratio: f64, escalation_level: RequirementLevel, ) -> Result<(), AdaptivePolicyError>
Record a new blocked-ratio observation for a target. Read more
Source§impl Debug for RegressionHistoryPolicy
impl Debug for RegressionHistoryPolicy
Auto Trait Implementations§
impl !Freeze for RegressionHistoryPolicy
impl RefUnwindSafe for RegressionHistoryPolicy
impl Send for RegressionHistoryPolicy
impl Sync for RegressionHistoryPolicy
impl Unpin for RegressionHistoryPolicy
impl UnsafeUnpin for RegressionHistoryPolicy
impl UnwindSafe for RegressionHistoryPolicy
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