| 251 | } |
| 252 | |
| 253 | func isOverThreshold(id string) bool { |
| 254 | notifyThresholdsLock.Lock() |
| 255 | defer notifyThresholdsLock.Unlock() |
| 256 | |
| 257 | // Get notify threshold and check if we reach the minimum incidents. |
| 258 | nt, ok := notifyThresholds[id] |
| 259 | if ok && !nt.expired() { |
| 260 | nt.Incidents++ |
| 261 | return nt.Incidents >= notifyThresholdMinIncidents |
| 262 | } |
| 263 | |
| 264 | // Add new entry. |
| 265 | notifyThresholds[id] = ¬ifyThreshold{ |
| 266 | FirstSeen: time.Now(), |
| 267 | Incidents: 1, |
| 268 | } |
| 269 | return false |
| 270 | } |
| 271 | |
| 272 | func cleanNotifyThreshold(ctx *mgr.WorkerCtx) error { |
| 273 | notifyThresholdsLock.Lock() |