class LitmusPaper::Service

Attributes

checks[R]

Public Class Methods

new(name, dependencies = [], checks = []) click to toggle source
# File lib/litmus_paper/service.rb, line 5
def initialize(name, dependencies = [], checks = [])
  @name = name
  @dependencies = dependencies
  @checks = checks
end

Public Instance Methods

_determine_forced_health() click to toggle source
# File lib/litmus_paper/service.rb, line 41
def _determine_forced_health
  _health_files.map do |status_file|
    LitmusPaper::Health.new(status_file.forced, status_file.content) if status_file.exists?
  end.compact.first
end
_health_files() click to toggle source
# File lib/litmus_paper/service.rb, line 37
def _health_files
  StatusFile.priority_check_order_for_service(@name)
end
current_health() click to toggle source
# File lib/litmus_paper/service.rb, line 11
def current_health
  forced_health = _determine_forced_health

  health = forced_health ? forced_health : LitmusPaper::Health.new
  @dependencies.each do |dependency|
    health.ensure(dependency)
  end

  @checks.each do |check|
    health.perform(check)
  end
  health
end
depends(dependency_class, *args) click to toggle source
# File lib/litmus_paper/service.rb, line 33
def depends(dependency_class, *args)
  @dependencies << dependency_class.new(*args)
end
measure_health(metric_class, options) click to toggle source
# File lib/litmus_paper/service.rb, line 25
def measure_health(metric_class, options)
  @checks << metric_class.new(options[:weight])
end
measure_health_with_args(metric_class, *args) click to toggle source
# File lib/litmus_paper/service.rb, line 29
def measure_health_with_args(metric_class, *args)
  @checks << metric_class.new(*args)
end