pharos/threshold_eval

Evaluate a Threshold against a decoded Measurement.

Returns a three-way verdict so callers can branch without reaching for nested case over the cartesian product of measurements and thresholds. Helper functions match every measurement variant exhaustively, so adding a new measurement kind surfaces as a compiler warning here.

Types

Three-way verdict for a (measurement, threshold) pair.

pub type Verdict {
  NotApplicable
  Healthy
  Breached
}

Constructors

  • NotApplicable

    The threshold doesn’t apply to this measurement kind. Caller should do nothing (don’t fire recover for unrelated measurements).

  • Healthy

    The threshold applies and is currently within limits.

  • Breached

    The threshold applies and is currently breached.

Values

pub fn evaluate(
  measurement: measurement.Measurement,
  threshold: config.Threshold,
) -> Verdict

Evaluate threshold against measurement and return a Verdict.

pub fn evaluate_probe(
  sample: dict.Dict(String, Float),
  threshold: probe.ProbeThreshold,
) -> Verdict

Evaluate a probe threshold against a decoded probe sample, returning the same Verdict as evaluate/2. A NotApplicable verdict means the threshold’s field is absent from this sample, so the caller should neither breach nor recover.

Search Document