Skip to content

Commit 5a36856

Browse files
authored
tiny refactor: use slices.Contains (#4631)
No change in behaviour. Signed-off-by: Solomon Jacobs <[email protected]>
1 parent f2fbb31 commit 5a36856

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

notify/util.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"log/slog"
2323
"net/http"
2424
"net/url"
25+
"slices"
2526
"strings"
2627

2728
"github.com/prometheus/common/version"
@@ -222,15 +223,7 @@ func (r *Retrier) Check(statusCode int, body io.Reader) (bool, error) {
222223
}
223224

224225
// 5xx responses are considered to be always retried.
225-
retry := statusCode/100 == 5
226-
if !retry {
227-
for _, code := range r.RetryCodes {
228-
if code == statusCode {
229-
retry = true
230-
break
231-
}
232-
}
233-
}
226+
retry := statusCode/100 == 5 || slices.Contains(r.RetryCodes, statusCode)
234227

235228
s := fmt.Sprintf("unexpected status code %v", statusCode)
236229
var details string

0 commit comments

Comments
 (0)