File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -95,13 +95,15 @@ func deduplicateAndRatelimit(
95
95
state * amstate.Store ,
96
96
maxActiveAlerts int ,
97
97
) []amstate.Alert {
98
- processed := []amstate.Alert {}
98
+ filtered := []amstate.Alert {}
99
99
100
100
activeAlerts := state .ActiveAlerts ()
101
101
102
+ addedJustNow := func () int { return len (filtered ) }
103
+
102
104
for _ , alert := range alerts {
103
105
// no more "room"?
104
- if len (activeAlerts ) >= maxActiveAlerts {
106
+ if ( len (activeAlerts ) + addedJustNow () ) >= maxActiveAlerts {
105
107
continue
106
108
}
107
109
@@ -110,10 +112,10 @@ func deduplicateAndRatelimit(
110
112
continue
111
113
}
112
114
113
- processed = append (processed , alert )
115
+ filtered = append (filtered , alert )
114
116
}
115
117
116
- return processed
118
+ return filtered
117
119
}
118
120
119
121
func getMaxFiringAlerts () (int , error ) {
You can’t perform that action at this time.
0 commit comments