Class: Sonic::ServiceChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/sonic/service_checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(protocol, host, port, path = nil, payload = nil, ssl_cert = nil, ssl_key = nil) ⇒ ServiceChecker

Returns a new instance of ServiceChecker.



14
15
16
17
18
19
20
21
22
# File 'lib/sonic/service_checker.rb', line 14

def initialize(protocol, host, port, path=nil, payload=nil, ssl_cert=nil, ssl_key=nil)
  @protocol = protocol
  @host     = host
  @port     = port
  @path     = path
  @payload  = payload
  @ssl_key  = ssl_key
  @ssl_cert  = ssl_cert
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



12
13
14
# File 'lib/sonic/service_checker.rb', line 12

def error
  @error
end

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/sonic/service_checker.rb', line 5

def host
  @host
end

#pathObject

Returns the value of attribute path.



7
8
9
# File 'lib/sonic/service_checker.rb', line 7

def path
  @path
end

#payloadObject

Returns the value of attribute payload.



8
9
10
# File 'lib/sonic/service_checker.rb', line 8

def payload
  @payload
end

#portObject

Returns the value of attribute port.



6
7
8
# File 'lib/sonic/service_checker.rb', line 6

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



4
5
6
# File 'lib/sonic/service_checker.rb', line 4

def protocol
  @protocol
end

#responseObject

Returns the value of attribute response.



11
12
13
# File 'lib/sonic/service_checker.rb', line 11

def response
  @response
end

#ssl_certObject

Returns the value of attribute ssl_cert.



10
11
12
# File 'lib/sonic/service_checker.rb', line 10

def ssl_cert
  @ssl_cert
end

#ssl_keyObject

Returns the value of attribute ssl_key.



9
10
11
# File 'lib/sonic/service_checker.rb', line 9

def ssl_key
  @ssl_key
end

Instance Method Details

#check_serviceObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sonic/service_checker.rb', line 24

def check_service()
  case protocol
  when :http, :https
    http = Protocol::HTTP.new(self)
    http.get
  when :amqp
    amqp = Protocol::AMQP.new(self)
    amqp.check
  when :tcp
    tcp = Protocol::TCP.new(self)
    tcp.send
  end
end