module EbDeployer::Utils
Constants
- BACKOFF_INITIAL_SLEEP
Public Instance Methods
backoff(error_class, retry_limit=9) { || ... }
click to toggle source
A util deal with throttling exceptions example:
backoff(Aws::EC2::Errors::RequestLimitExceeded) do ... end
# File lib/eb_deployer/utils.rb, line 10 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
reject_nil(hash)
click to toggle source
# File lib/eb_deployer/utils.rb, line 29 def reject_nil(hash) hash.reject{| k, v| v.nil?} end
symbolize_keys(hash)
click to toggle source
convert top level key in a hash to symbol
# File lib/eb_deployer/utils.rb, line 24 def symbolize_keys(hash) hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} end