Class: What::Monitor
- Inherits:
-
Object
- Object
- What::Monitor
- Defined in:
- lib/what/monitor.rb
Instance Method Summary collapse
-
#go! ⇒ Object
don’t worry, this method name is ironic.
- #status ⇒ Object
Instance Method Details
#go! ⇒ Object
don’t worry, this method name is ironic
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/what/monitor.rb', line 4 def go! # For now, use a hash as the centralized collection point for data. We # can't use a method on the module because Celluloid will block that call # until after whatever method is currently running, which could be # unacceptably slow. We could use a fancy thread-safe data structure # instead of a hash, but the GIL means hash assignment and reading are # safe as long as we're on MRI. @results = {} @modules = Config['modules'].map do |config_hash| name = Helpers.camelize(config_hash.delete('type')) klass = Modules.const_get(name) instance = klass.new(config_hash, @results) { class: klass, config_hash: config_hash, module: instance, id: instance.identifier } end @modules.each do |mod| mod[:module].async.start_monitoring end end |
#status ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/what/monitor.rb', line 29 def status statuses = [] healths = [] @modules.each do |mod| status = @results[mod[:id]] || {"health" => nil} healths << status['health'] statuses << status if status["error"] mod[:module].async.start_monitoring end end {"health" => Helpers.overall_health(healths), "details" => statuses} end |