DEV: Add the ability for problem checks to specify 'max blips' (#26388)

This was originally introduced in #26071, but that PR was closed, because the requirements changed. This PR lifts only the relevant parts, since they are a prerequisite for the new admin notice system.
This commit is contained in:
Ted Johansson 2024-03-27 10:07:56 +08:00 committed by GitHub
parent cc8f0a79e2
commit 5875b25e68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -21,6 +21,13 @@ class ProblemCheck
#
config_accessor :retry_after, default: 30.seconds, instance_writer: false
# How many consecutive times the check can fail without notifying admins.
# This can be used to give some leeway for transient problems. Note that
# retries are not counted. So a check that ultimately fails after e.g. two
# retries is counted as one "blip".
#
config_accessor :max_blips, default: 0, instance_writer: false
def self.[](key)
key = key.to_sym

View File

@ -27,6 +27,12 @@ class ProblemCheckTracker < ActiveRecord::Base
def check
ProblemCheck[identifier]
end
private
def sound_the_alarm?
blips > check.max_blips
end
end
# == Schema Information