Class: Elasticity::Looper
- Inherits:
-
Object
- Object
- Elasticity::Looper
- Defined in:
- lib/elasticity/looper.rb
Instance Method Summary collapse
- #go ⇒ Object
-
#initialize(on_retry_check, on_wait = nil, poll_interval = 60) ⇒ Looper
constructor
A new instance of Looper.
Constructor Details
#initialize(on_retry_check, on_wait = nil, poll_interval = 60) ⇒ Looper
Returns a new instance of Looper.
5 6 7 8 9 |
# File 'lib/elasticity/looper.rb', line 5 def initialize(on_retry_check, on_wait = nil, poll_interval = 60) @on_retry_check = on_retry_check @on_wait = on_wait @poll_interval = poll_interval end |
Instance Method Details
#go ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/elasticity/looper.rb', line 11 def go start_time = Time.now loop do should_continue, *results = @on_retry_check.call return unless should_continue @on_wait.call(Time.now - start_time, *results) if @on_wait sleep(@poll_interval) end end |