Sha256: cdcf38d0d2a7487c3cc9d892642b190c8277bcd5ea65b0aa5c065159865385d5

Contents?: true

Size: 574 Bytes

Versions: 1

Compression:

Stored size: 574 Bytes

Contents

# encoding: utf-8
require "belzebuth/wait_condition/base"
require "uri"
require "net/http"

module Belzebuth module WaitCondition
  class Api < Base
    MAX_SLEEP_TIME = 10

    def initialize(uri, max_sleep_time = MAX_SLEEP_TIME)
      @uri = URI(uri)
      @sleep_time = 0
      @max_sleep_time = max_sleep_time
    end

    def call(process)
      Net::HTTP.get(@uri)
      true
    rescue => e
      @sleep_time += 1
      @sleep_time = [@sleep_time, @max_sleep_time].min
      false
    end

    def sleep_time_between_condition
      @sleep_time
    end
  end
end end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
belzebuth-0.2.3 lib/belzebuth/wait_condition/api.rb