Class: Healthier::Doctor
- Inherits:
-
Object
- Object
- Healthier::Doctor
- Defined in:
- lib/healthier/doctor.rb
Overview
Health Checker Doctor
Constant Summary collapse
- SUCCESS =
:success- FAILURE =
:failure
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config = nil) ⇒ Doctor
constructor
A new instance of Doctor.
- #ping ⇒ Object
- #running? ⇒ Boolean
- #up? ⇒ Boolean
Constructor Details
#initialize(config = nil) ⇒ Doctor
Returns a new instance of Doctor.
9 10 11 12 |
# File 'lib/healthier/doctor.rb', line 9 def initialize(config = nil) @config = config || Healthier.depends_on['healthier'] || {} @connectors = load_connectors end |
Class Method Details
.ping! ⇒ Object
14 15 16 |
# File 'lib/healthier/doctor.rb', line 14 def self.ping! new.ping end |
.running? ⇒ Boolean
22 23 24 |
# File 'lib/healthier/doctor.rb', line 22 def self.running? new.running? end |
.up? ⇒ Boolean
18 19 20 |
# File 'lib/healthier/doctor.rb', line 18 def self.up? new.up? end |
Instance Method Details
#ping ⇒ Object
37 38 39 40 41 |
# File 'lib/healthier/doctor.rb', line 37 def ping @config.fetch('depends_on', []).each_with_object({}) do |service_config, result| result[service_config['name']] = diagnose(service_config) end end |
#running? ⇒ Boolean
32 33 34 35 |
# File 'lib/healthier/doctor.rb', line 32 def running? # Check if all configured services are running ping.values.all? { |service_result| service_result[:status] == SUCCESS } end |
#up? ⇒ Boolean
26 27 28 29 30 |
# File 'lib/healthier/doctor.rb', line 26 def up? # Basic health check - just return true for now # Could be extended to check basic application health true end |