Class: AppHealth::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/apphealth/checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url = nil) ⇒ Checker

Returns a new instance of Checker.



5
6
7
8
9
10
11
12
13
# File 'lib/apphealth/checker.rb', line 5

def initialize(url = nil)
  url ||= Config.default_url

  @uri = URI.parse(url)
  @threads = []
  @servers = Config.servers.map do |server|
    Server.new(server)
  end
end

Instance Attribute Details

#serversObject

Returns the value of attribute servers.



3
4
5
# File 'lib/apphealth/checker.rb', line 3

def servers
  @servers
end

#threadsObject

Returns the value of attribute threads.



3
4
5
# File 'lib/apphealth/checker.rb', line 3

def threads
  @threads
end

#uriObject

Returns the value of attribute uri.



3
4
5
# File 'lib/apphealth/checker.rb', line 3

def uri
  @uri
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/apphealth/checker.rb', line 15

def run
  servers.select(&:unchecked?).each do |server|
    threads << Thread.new do
      server.check(uri)
    end
  end

  threads.each(&:join)

  self
end