Files
OrbitWard/worker/app/jobs/alerts.py
T
2026-05-22 17:36:40 -06:00

17 lines
559 B
Python

from dataclasses import dataclass
@dataclass(frozen=True)
class AlertEvaluation:
should_open_incident: bool
should_resolve_incident: bool
message: str
def evaluate_status_rule(current_status: str, failure_count: int, threshold: int) -> AlertEvaluation:
if current_status == "up":
return AlertEvaluation(False, True, "Monitor recovered")
if failure_count >= threshold:
return AlertEvaluation(True, False, f"Monitor failed {failure_count} times")
return AlertEvaluation(False, False, "Failure threshold not reached")