Class: LitmusPaper::AgentCheckHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/litmus_paper/agent_check_handler.rb

Class Method Summary collapse

Class Method Details

.handle(service) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/litmus_paper/agent_check_handler.rb', line 3

def self.handle(service)
  output = []
  health = LitmusPaper.check_service(service)
  if health.nil?
    output << "failed#NOT_FOUND"
  else
    case health.direction
    when :up, :health
      output << "ready" # administrative state
      output << "up" # operational state
    when :down
      output << "drain" # administrative state
    when :none
      if health.ok?
        output << "ready" # administrative state
        output << "up" # operational state
      else
        output << "down" # operational state
      end
    end
    output << "#{health.value.to_s}%"
  end
  output.join("\t")
end