Sha256: afc1a5e6f232768c4b2438284b61d09d105568eb747e1a88497f043ebb73e5a9

Contents?: true

Size: 649 Bytes

Versions: 6

Compression:

Stored size: 649 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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
eb_deployer-0.4.4.beta5 lib/eb_deployer/utils.rb
eb_deployer-0.4.4.beta4 lib/eb_deployer/utils.rb
eb_deployer-0.4.4.beta3 lib/eb_deployer/utils.rb
eb_deployer-0.4.4.beta2 lib/eb_deployer/utils.rb
eb_deployer-0.4.4.beta1 lib/eb_deployer/utils.rb
eb_deployer-0.4.3 lib/eb_deployer/utils.rb