Class: RailsHealthChecks::CheckRegistry
- Inherits:
-
Object
- Object
- RailsHealthChecks::CheckRegistry
- Defined in:
- lib/rails_health_checks/check_registry.rb
Constant Summary collapse
- BUILT_INS =
{ database: -> { Checks::DatabaseCheck.new }, cache: -> { Checks::CacheCheck.new }, sidekiq: -> { Checks::SidekiqCheck.new(queue_size: RailsHealthChecks.configuration.sidekiq_queue_size) }, solid_queue: -> { Checks::SolidQueueCheck.new(job_count: RailsHealthChecks.configuration.solid_queue_job_count) }, good_job: -> { Checks::GoodJobCheck.new(latency: RailsHealthChecks.configuration.good_job_latency) }, resque: -> { Checks::ResqueCheck.new(queue_size: RailsHealthChecks.configuration.resque_queue_size) }, memory: -> { Checks::MemoryCheck.new(threshold: RailsHealthChecks.configuration.memory_threshold) }, http: -> { Checks::HttpCheck.new( url: RailsHealthChecks.configuration.http_url, expected_status: RailsHealthChecks.configuration.http_expected_status ) }, disk: -> { Checks::DiskCheck.new( warn_threshold: RailsHealthChecks.configuration.disk_warn_threshold, critical_threshold: RailsHealthChecks.configuration.disk_critical_threshold, path: RailsHealthChecks.configuration.disk_path ) } }.freeze
Class Method Summary collapse
Class Method Details
.build(check_names) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rails_health_checks/check_registry.rb', line 26 def self.build(check_names) custom = RailsHealthChecks.configuration.custom_checks check_names.each_with_object({}) do |name, hash| if BUILT_INS.key?(name) hash[name] = BUILT_INS[name].call elsif custom.key?(name) hash[name] = custom[name].dup else available = (BUILT_INS.keys + custom.keys).join(", ") raise ArgumentError, "Unknown check: #{name}. Available: #{available}" end end end |
.run(checks, timeout:) ⇒ Object
40 41 42 |
# File 'lib/rails_health_checks/check_registry.rb', line 40 def self.run(checks, timeout:) checks.transform_values { |check| run_check(check, timeout: timeout) } end |