Class: KumoDockerCloud::ServiceChecker

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(checks = [], timeout = 300, quiet_time = 5) ⇒ ServiceChecker

Returns a new instance of ServiceChecker.



7
8
9
10
11
# File 'lib/kumo_dockercloud/service_checker.rb', line 7

def initialize(checks = [], timeout = 300, quiet_time = 5)
  @checks = checks
  @timeout = timeout
  @quiet_time = quiet_time
end

Instance Attribute Details

#checksObject (readonly)

Returns the value of attribute checks.



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

def checks
  @checks
end

#quiet_timeObject (readonly)

Returns the value of attribute quiet_time.



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

def quiet_time
  @quiet_time
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



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

def timeout
  @timeout
end

Instance Method Details

#verify(service) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/kumo_dockercloud/service_checker.rb', line 13

def verify(service)
  Timeout::timeout(timeout) do

    while any_check_failing?(service)
      ConsoleJockey.write_char '.'
      sleep(quiet_time)
    end

  end
rescue Timeout::Error
  if @error_messages.length > 0
    raise KumoDockerCloud::ServiceDeployError.new("One or more checks failed to pass within the timeout.#{@error_messages.join}")
  else
    raise KumoDockerCloud::ServiceDeployError.new("One or more checks failed to pass within the timeout. I'd show you what went wrong but the checks were lambdas so I can't. Maybe you should update your usage to the new ServiceCheck object instead of lambdas?")
  end
end