23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/poller/poller.rb', line 23
def check
@timeout ||= Timeout.new(@timeout_seconds)
tries = 0
check_started_at = Time.now
last_sample_took = 0
while !@timeout.occured?
Kernel.sleep sleep_time(@period, last_sample_took)
sample_started_at = Time.now
response = @probe.sample
satisfied = @probe.satisfied?
last_sample_took = Time.now - sample_started_at
tries += 1
return [response, Time.now - sample_started_at] if satisfied
end
raise RuntimeError, "Timeout period has been exceeded for Poller (#{@name})." \
+ " Poller tried #{tries} times which in total took #{Time.now - check_started_at} seconds."
end
|