Sha256: c894463f4545c6c15198bff7af3216cb07143c47a1c4fbc74e84481d515dbb0d

Contents?: true

Size: 489 Bytes

Versions: 32

Compression:

Stored size: 489 Bytes

Contents

module Elasticity

  class Looper

    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

    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

  end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
elasticity-6.0.14 lib/elasticity/looper.rb
elasticity-6.0.13 lib/elasticity/looper.rb
elasticity-6.0.12 lib/elasticity/looper.rb
elasticity-6.0.11 lib/elasticity/looper.rb
elasticity-6.0.10 lib/elasticity/looper.rb
elasticity-6.0.9 lib/elasticity/looper.rb
elasticity-6.0.8 lib/elasticity/looper.rb
elasticity-6.0.7 lib/elasticity/looper.rb
elasticity-6.0.6 lib/elasticity/looper.rb
elasticity-6.0.5 lib/elasticity/looper.rb
elasticity-6.0.4 lib/elasticity/looper.rb
elasticity-6.0.3 lib/elasticity/looper.rb
elasticity-6.0.2 lib/elasticity/looper.rb
elasticity-6.0.1 lib/elasticity/looper.rb
elasticity-6.0 lib/elasticity/looper.rb
elasticity-5.0.3 lib/elasticity/looper.rb
elasticity-5.0.2 lib/elasticity/looper.rb
elasticity-5.0.1 lib/elasticity/looper.rb
elasticity-4.0.5 lib/elasticity/looper.rb
elasticity-5.0 lib/elasticity/looper.rb