Class: RailsHealthChecks::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_health_checks/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rails_health_checks/configuration.rb', line 11

def initialize
  @checks = [:database]
  @timeout = 5
  @allowed_ips = nil
  @token = nil
  @authenticate_block = 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
  @custom_checks = {}
  @groups = {}
  @disabled_checks = {}
end

Instance Attribute Details

#allowed_ipsObject

Returns the value of attribute allowed_ips.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def allowed_ips
  @allowed_ips
end

#authenticate_blockObject (readonly)

Returns the value of attribute authenticate_block.



9
10
11
# File 'lib/rails_health_checks/configuration.rb', line 9

def authenticate_block
  @authenticate_block
end

#checksObject



32
33
34
35
# File 'lib/rails_health_checks/configuration.rb', line 32

def checks
  disabled = @disabled_checks.filter_map { |name, envs| name if envs.include?(Rails.env.to_s) }
  @checks - disabled
end

#custom_checksObject (readonly)

Returns the value of attribute custom_checks.



9
10
11
# File 'lib/rails_health_checks/configuration.rb', line 9

def custom_checks
  @custom_checks
end

#disk_critical_thresholdObject

Returns the value of attribute disk_critical_threshold.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def disk_critical_threshold
  @disk_critical_threshold
end

#disk_pathObject

Returns the value of attribute disk_path.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def disk_path
  @disk_path
end

#disk_warn_thresholdObject

Returns the value of attribute disk_warn_threshold.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def disk_warn_threshold
  @disk_warn_threshold
end

#good_job_latencyObject

Returns the value of attribute good_job_latency.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def good_job_latency
  @good_job_latency
end

#groupsObject (readonly)

Returns the value of attribute groups.



9
10
11
# File 'lib/rails_health_checks/configuration.rb', line 9

def groups
  @groups
end

#http_expected_statusObject

Returns the value of attribute http_expected_status.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def http_expected_status
  @http_expected_status
end

#http_urlObject

Returns the value of attribute http_url.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def http_url
  @http_url
end

#memory_thresholdObject

Returns the value of attribute memory_threshold.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def memory_threshold
  @memory_threshold
end

#resque_queue_sizeObject

Returns the value of attribute resque_queue_size.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def resque_queue_size
  @resque_queue_size
end

#sidekiq_queue_sizeObject

Returns the value of attribute sidekiq_queue_size.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def sidekiq_queue_size
  @sidekiq_queue_size
end

#solid_queue_job_countObject

Returns the value of attribute solid_queue_job_count.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def solid_queue_job_count
  @solid_queue_job_count
end

#timeoutObject

Returns the value of attribute timeout.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def timeout
  @timeout
end

#tokenObject

Returns the value of attribute token.



6
7
8
# File 'lib/rails_health_checks/configuration.rb', line 6

def token
  @token
end

Instance Method Details

#authenticate(&block) ⇒ Object



37
38
39
# File 'lib/rails_health_checks/configuration.rb', line 37

def authenticate(&block)
  @authenticate_block = block
end

#disable(name, **opts) ⇒ Object



41
42
43
44
45
# File 'lib/rails_health_checks/configuration.rb', line 41

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



47
48
49
# File 'lib/rails_health_checks/configuration.rb', line 47

def group(name, check_names)
  @groups[name] = check_names
end

#register(name, check) ⇒ Object



51
52
53
54
# File 'lib/rails_health_checks/configuration.rb', line 51

def register(name, check)
  @custom_checks[name] = check
  @checks << name unless @checks.include?(name)
end