Sha256: 1946adfa5a01ef1368493c107e448d954a6402204e74be686fb885292778489f

Contents?: true

Size: 1.14 KB

Versions: 53

Compression:

Stored size: 1.14 KB

Contents

module GovukHealthcheck
  class ThresholdCheck
    def status
      if value >= critical_threshold
        :critical
      elsif value >= warning_threshold
        :warning
      else
        :ok
      end
    end

    def message
      if value >= critical_threshold
        "#{value} is above the critical threshold (#{critical_threshold})"
      elsif value >= warning_threshold
        "#{value} is above the warning threshold (#{warning_threshold})"
      else
        "#{value} is below the critical and warning thresholds"
      end
    end

    def details
      {
        value: value,
        total: total,
        thresholds: {
          critical: critical_threshold,
          warning: warning_threshold,
        },
      }
    end

    def value
      raise "This method must be overridden to be the check value."
    end

    def total
      nil # This method can be overriden to provide the total for the check.
    end

    def critical_threshold
      raise "This method must be overriden to be the critical threshold."
    end

    def warning_threshold
      raise "This method must be overriden to be the warning threshold."
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
govuk_app_config-2.10.0 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.9.1 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.9.0 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.8.4 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.8.3 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.8.2 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.8.1 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.8.0 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.7.1 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.7.0 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.6.0 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.5.2 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.5.1 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.5.0 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.4.1 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.4.0 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.3.0 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.2.2 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.2.1 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb
govuk_app_config-2.2.0 lib/govuk_app_config/govuk_healthcheck/threshold_check.rb