class Hcheck::Configuration::Service

Main service class One to one servcie class is created from hcheck.yml top level keys includes corresponsing check module; which includes status method

Constants

NOT_IMPLEMENTED_MSG

Attributes

check_not_available[R]
name[R]

Public Class Methods

new(service, options) click to toggle source
# File lib/hcheck/configuration/service.rb, line 18
def initialize(service, options)
  @name = service.to_s
  @check = options.delete('check')
  @options = options.symbolize_keys
  if mod = load_mod
    singleton_class.send(:include, mod)
  else
    @check_not_available = true
  end
end

Public Instance Methods

check() click to toggle source
# File lib/hcheck/configuration/service.rb, line 29
def check
  {
    name: @name,
    desc: @check,
    status: @check_not_available ? NOT_IMPLEMENTED_MSG : check_status
  }
end

Private Instance Methods

check_status() click to toggle source
# File lib/hcheck/configuration/service.rb, line 39
def check_status
  status(@options)
  'ok'
rescue StandardError => e
  Hcheck.logger.error "[HCheck] #{e.class.name} #{e.message}"
  'bad'
end
load_mod() click to toggle source
# File lib/hcheck/configuration/service.rb, line 47
def load_mod
  Hcheck::Checks.const_get(@name.capitalize)
rescue NameError
  nil
end