MCPcopy Create free account
hub / github.com/diillson/chatcli / AddAlert

Method AddAlert

k8s/store.go:60–81  ·  view source on GitHub ↗

AddAlert adds an alert to the store. Duplicates (same Type+Object) are skipped to prevent alert accumulation from repeated poll cycles detecting the same condition.

(alert Alert)

Source from the content-addressed store, hash-verified

58// AddAlert adds an alert to the store. Duplicates (same Type+Object) are skipped
59// to prevent alert accumulation from repeated poll cycles detecting the same condition.
60func (s *ObservabilityStore) AddAlert(alert Alert) {
61 s.mu.Lock()
62 defer s.mu.Unlock()
63
64 // Dedup: skip if same Type+Object already exists in window
65 for _, existing := range s.alerts {
66 if existing.Type == alert.Type && existing.Object == alert.Object {
67 return
68 }
69 }
70
71 s.alerts = append(s.alerts, alert)
72 // Keep only alerts within the window
73 cutoff := time.Now().Add(-s.window)
74 filtered := s.alerts[:0]
75 for _, a := range s.alerts {
76 if a.Timestamp.After(cutoff) {
77 filtered = append(filtered, a)
78 }
79 }
80 s.alerts = filtered
81}
82
83// LatestSnapshot returns the most recent snapshot, if any.
84func (s *ObservabilityStore) LatestSnapshot() (ResourceSnapshot, bool) {

Callers 11

makeCriticalStoreFunction · 0.95
TestAddAlertFunction · 0.95
TestAddAlert_DedupFunction · 0.95
TestStatsFunction · 0.95
detectAnomaliesMethod · 0.80
detectNodeAnomaliesMethod · 0.80

Calls 3

LockMethod · 0.80
UnlockMethod · 0.80
AddMethod · 0.80