Module: EbDeployer::Utils
- Included in:
- ConfigLoader, Environment, EventPoller
- Defined in:
- lib/eb_deployer/utils.rb
Constant Summary collapse
- BACKOFF_INITIAL_SLEEP =
1
Instance Method Summary collapse
-
#backoff(error_class, retry_limit = 9, &block) ⇒ Object
A util deal with throttling exceptions example: backoff(AWS::EC2::Errors::RequestLimitExceeded) do ...
-
#symbolize_keys(hash) ⇒ Object
convert top level key in a hash to symbol.
Instance Method Details
#backoff(error_class, retry_limit = 9, &block) ⇒ Object
A util deal with throttling exceptions example: backoff(AWS::EC2::Errors::RequestLimitExceeded) do ... end
10 11 12 13 14 15 16 17 18 19 20 21 |
# 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 |
#symbolize_keys(hash) ⇒ Object
convert top level key in a hash to symbol
24 25 26 |
# File 'lib/eb_deployer/utils.rb', line 24 def symbolize_keys(hash) hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} end |