Sha256: 23b62e9286acc0566cb00a0c38628119368cfd2e339507f2786d0fcdb50f0cf1

Contents?: true

Size: 718 Bytes

Versions: 25

Compression:

Stored size: 718 Bytes

Contents

module EbDeployer
  module Utils
    BACKOFF_INITIAL_SLEEP = 1

    # A util deal with throttling exceptions
    # example:
    #  backoff(AWS::EC2::Errors::RequestLimitExceeded) do
    #     ...
    #  end
    def backoff(error_class, retry_limit=9, &block)
      next_sleep = BACKOFF_INITIAL_SLEEP
      begin
        yield
      rescue error_class
        raise if retry_limit == 0
        sleep(next_sleep)
        next_sleep *= 2
        retry_limit -= 1
        retry
      end
    end

    # convert top level key in a hash to symbol
    def symbolize_keys(hash)
      hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
    end


    def reject_nil(hash)
      hash.reject{| k, v| v.nil?}
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
eb_deployer-0.6.1 lib/eb_deployer/utils.rb
eb_deployer-0.6.0 lib/eb_deployer/utils.rb
eb_deployer-0.6.0.beta6 lib/eb_deployer/utils.rb
eb_deployer-0.6.0.beta5 lib/eb_deployer/utils.rb
eb_deployer-0.6.0.beta4 lib/eb_deployer/utils.rb
eb_deployer-0.6.0.beta3 lib/eb_deployer/utils.rb
eb_deployer-0.6.0.beta2 lib/eb_deployer/utils.rb
eb_deployer-0.5.2 lib/eb_deployer/utils.rb
eb_deployer-0.6.0.beta1 lib/eb_deployer/utils.rb
eb_deployer-0.5.1.beta3 lib/eb_deployer/utils.rb
eb_deployer-0.5.1.beta2 lib/eb_deployer/utils.rb
eb_deployer-0.5.1.beta1 lib/eb_deployer/utils.rb
eb_deployer-0.5.0 lib/eb_deployer/utils.rb
eb_deployer-0.4.13 lib/eb_deployer/utils.rb
eb_deployer-0.4.12 lib/eb_deployer/utils.rb
eb_deployer-0.4.11 lib/eb_deployer/utils.rb
eb_deployer-0.4.10 lib/eb_deployer/utils.rb
eb_deployer-0.4.9 lib/eb_deployer/utils.rb
eb_deployer-0.4.8 lib/eb_deployer/utils.rb
eb_deployer-0.4.7.beta1 lib/eb_deployer/utils.rb