Class: HealthCheck
- Inherits:
-
Object
- Object
- HealthCheck
- Defined in:
- lib/liquid/health_checks.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- @@checks =
{}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.healthy? ⇒ Boolean
43 44 45 |
# File 'lib/liquid/health_checks.rb', line 43 def self.healthy? @healthy.nil? ? run.values.all?(&:healthy?) : @healthy end |
.poll(interval = 5) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/liquid/health_checks.rb', line 36 def self.poll(interval = 5) loop do @healthy = run.values.all?(&:healthy?) sleep(interval) end end |
.run ⇒ Object
29 30 31 32 33 34 |
# File 'lib/liquid/health_checks.rb', line 29 def self.run @@checks.inject({}) do |result, (name, handler)| result[name] = handler.new.execute result end end |
Instance Method Details
#execute ⇒ Object
47 48 49 50 51 |
# File 'lib/liquid/health_checks.rb', line 47 def execute check rescue => e Result.new(false, "failed to execute check", e) end |