Class: RailsHealthChecks::Configuration
- Inherits:
-
Object
- Object
- RailsHealthChecks::Configuration
- Defined in:
- lib/rails_health_checks/configuration.rb
Constant Summary collapse
- BUILT_IN_NAMES =
%i[database cache redis sidekiq solid_queue good_job resque disk memory http smtp].freeze
Instance Attribute Summary collapse
-
#allowed_ips ⇒ Object
Returns the value of attribute allowed_ips.
-
#authenticate_block ⇒ Object
readonly
Returns the value of attribute authenticate_block.
-
#cache_duration ⇒ Object
Returns the value of attribute cache_duration.
- #checks ⇒ Object
-
#custom_checks ⇒ Object
readonly
Returns the value of attribute custom_checks.
-
#disk_critical_threshold ⇒ Object
Returns the value of attribute disk_critical_threshold.
-
#disk_path ⇒ Object
Returns the value of attribute disk_path.
-
#disk_warn_threshold ⇒ Object
Returns the value of attribute disk_warn_threshold.
-
#good_job_latency ⇒ Object
Returns the value of attribute good_job_latency.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#http_expected_status ⇒ Object
Returns the value of attribute http_expected_status.
-
#http_headers ⇒ Object
Returns the value of attribute http_headers.
-
#http_url ⇒ Object
Returns the value of attribute http_url.
-
#memory_threshold ⇒ Object
Returns the value of attribute memory_threshold.
-
#redis_url ⇒ Object
Returns the value of attribute redis_url.
-
#resque_queue_size ⇒ Object
Returns the value of attribute resque_queue_size.
-
#sidekiq_queue_size ⇒ Object
Returns the value of attribute sidekiq_queue_size.
-
#smtp_address ⇒ Object
Returns the value of attribute smtp_address.
-
#smtp_port ⇒ Object
Returns the value of attribute smtp_port.
-
#solid_queue_job_count ⇒ Object
Returns the value of attribute solid_queue_job_count.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #authenticate(&block) ⇒ Object
- #disable(name, **opts) ⇒ Object
- #group(name, check_names) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #register(name, check, timeout: nil) ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rails_health_checks/configuration.rb', line 18 def initialize @checks = [:database] @timeout = 5 @cache_duration = nil @allowed_ips = nil @token = nil @authenticate_block = nil @redis_url = nil @smtp_address = nil @smtp_port = nil @sidekiq_queue_size = nil @solid_queue_job_count = nil @good_job_latency = nil @resque_queue_size = nil @disk_warn_threshold = nil @disk_critical_threshold = nil @disk_path = "/" @memory_threshold = nil @http_url = nil @http_expected_status = 200 @http_headers = {} @custom_checks = {} @groups = {} @disabled_checks = {} end |
Instance Attribute Details
#allowed_ips ⇒ Object
Returns the value of attribute allowed_ips.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def allowed_ips @allowed_ips end |
#authenticate_block ⇒ Object (readonly)
Returns the value of attribute authenticate_block.
16 17 18 |
# File 'lib/rails_health_checks/configuration.rb', line 16 def authenticate_block @authenticate_block end |
#cache_duration ⇒ Object
Returns the value of attribute cache_duration.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def cache_duration @cache_duration end |
#checks ⇒ Object
44 45 46 47 |
# File 'lib/rails_health_checks/configuration.rb', line 44 def checks disabled = @disabled_checks.filter_map { |name, envs| name if envs.include?(Rails.env.to_s) } @checks - disabled end |
#custom_checks ⇒ Object (readonly)
Returns the value of attribute custom_checks.
16 17 18 |
# File 'lib/rails_health_checks/configuration.rb', line 16 def custom_checks @custom_checks end |
#disk_critical_threshold ⇒ Object
Returns the value of attribute disk_critical_threshold.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def disk_critical_threshold @disk_critical_threshold end |
#disk_path ⇒ Object
Returns the value of attribute disk_path.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def disk_path @disk_path end |
#disk_warn_threshold ⇒ Object
Returns the value of attribute disk_warn_threshold.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def disk_warn_threshold @disk_warn_threshold end |
#good_job_latency ⇒ Object
Returns the value of attribute good_job_latency.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def good_job_latency @good_job_latency end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
16 17 18 |
# File 'lib/rails_health_checks/configuration.rb', line 16 def groups @groups end |
#http_expected_status ⇒ Object
Returns the value of attribute http_expected_status.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def http_expected_status @http_expected_status end |
#http_headers ⇒ Object
Returns the value of attribute http_headers.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def http_headers @http_headers end |
#http_url ⇒ Object
Returns the value of attribute http_url.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def http_url @http_url end |
#memory_threshold ⇒ Object
Returns the value of attribute memory_threshold.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def memory_threshold @memory_threshold end |
#redis_url ⇒ Object
Returns the value of attribute redis_url.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def redis_url @redis_url end |
#resque_queue_size ⇒ Object
Returns the value of attribute resque_queue_size.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def resque_queue_size @resque_queue_size end |
#sidekiq_queue_size ⇒ Object
Returns the value of attribute sidekiq_queue_size.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def sidekiq_queue_size @sidekiq_queue_size end |
#smtp_address ⇒ Object
Returns the value of attribute smtp_address.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def smtp_address @smtp_address end |
#smtp_port ⇒ Object
Returns the value of attribute smtp_port.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def smtp_port @smtp_port end |
#solid_queue_job_count ⇒ Object
Returns the value of attribute solid_queue_job_count.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def solid_queue_job_count @solid_queue_job_count end |
#timeout ⇒ Object
Returns the value of attribute timeout.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def timeout @timeout end |
#token ⇒ Object
Returns the value of attribute token.
10 11 12 |
# File 'lib/rails_health_checks/configuration.rb', line 10 def token @token end |
Instance Method Details
#authenticate(&block) ⇒ Object
49 50 51 |
# File 'lib/rails_health_checks/configuration.rb', line 49 def authenticate(&block) @authenticate_block = block end |
#disable(name, **opts) ⇒ Object
53 54 55 56 57 |
# File 'lib/rails_health_checks/configuration.rb', line 53 def disable(name, **opts) envs = Array(opts.fetch(:in)).map(&:to_s) @disabled_checks[name] ||= [] @disabled_checks[name].concat(envs) end |
#group(name, check_names) ⇒ Object
59 60 61 |
# File 'lib/rails_health_checks/configuration.rb', line 59 def group(name, check_names) @groups[name] = check_names end |
#register(name, check, timeout: nil) ⇒ Object
63 64 65 66 67 |
# File 'lib/rails_health_checks/configuration.rb', line 63 def register(name, check, timeout: nil) check.timeout = timeout @custom_checks[name] = check @checks << name unless @checks.include?(name) end |
#validate! ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rails_health_checks/configuration.rb', line 69 def validate! all_checks = @checks + @groups.values.flatten all_checks.uniq.each do |name| next if BUILT_IN_NAMES.include?(name) || @custom_checks.key?(name) raise ConfigurationError, "Unknown check :#{name}. Built-ins: #{BUILT_IN_NAMES.join(', ')}" end if @checks.include?(:http) && @http_url.nil? raise ConfigurationError, "config.checks includes :http but config.http_url is not set" end end |