class Leafy::Health::Registry

Attributes

health[R]

state ofthe registry

Public Class Methods

new() click to toggle source
# File leafy-health/lib/leafy/health/registry.rb, line 10
def initialize
  @health = com.codahale.metrics.health.HealthCheckRegistry.new
end

Public Instance Methods

names() click to toggle source

the names of all registered HealthCheck

@return [Array<String>] names of HealthCheck in order of their registration

# File leafy-health/lib/leafy/health/registry.rb, line 42
def names
  @health.names.to_a
end
register(name, check = nil, &block ) click to toggle source

register a HealthCheck under a given name

@param [String] name @param [String] instead of block any check object which responds to 'call' @yieldparam [HealthCheckRegistry::HealthCheck] which has convienient methods to create healthy and unhealthy results with message @yieldreturn [String] if the healthcheck fails return the message @yieldreturn [NilClass] if the healthcheck succeeds @yieldreturn [com.codahale.metrics.health.HealthCheck::Result] if the check produces its own result object

# File leafy-health/lib/leafy/health/registry.rb, line 22
def register(name, check = nil, &block )
  if check and not block_given? and check.is_a? com.codahale.metrics.health.HealthCheck
    @health.register( name, check )
  elsif check.nil? and block_given?
    @health.register( name, HealthCheck.new( &block ) )
  else
    raise 'needs either a block and object with call method'
  end
end
unregister(name) click to toggle source

unregister a HealthCheck for a given name

@param [String] name

# File leafy-health/lib/leafy/health/registry.rb, line 35
def unregister(name)
  @health.unregister(name)
end