Module: EbDeployer::Utils
- Included in:
- AWSDriver::Beanstalk, ConfigLoader, EbEnvironment, Environment, EventPoller, ThrottlingHandling
- 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 …
- #reject_nil(hash) ⇒ Object
-
#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 |
#reject_nil(hash) ⇒ Object
29 30 31 |
# File 'lib/eb_deployer/utils.rb', line 29 def reject_nil(hash) hash.reject{| k, v| v.nil?} 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 |