Sha256: d7ced3ceaf86f30e853bf2a9dc7e4a6d3f9ff52aed25cc3cd7215bf58ef28ad9

Contents?: true

Size: 718 Bytes

Versions: 9

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

9 entries across 9 versions & 3 rubygems

Version Path
man_eb_deployer-0.8.0 lib/eb_deployer/utils.rb
eb_deployer_updated-0.8.1 lib/eb_deployer/utils.rb
eb_deployer_updated-0.8.0 lib/eb_deployer/utils.rb
eb_deployer-0.7.0 lib/eb_deployer/utils.rb
eb_deployer-0.6.6 lib/eb_deployer/utils.rb
eb_deployer-0.6.5 lib/eb_deployer/utils.rb
eb_deployer-0.6.4 lib/eb_deployer/utils.rb
eb_deployer-0.6.3 lib/eb_deployer/utils.rb
eb_deployer-0.6.2 lib/eb_deployer/utils.rb