infopark-aws_utils 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/infopark/aws_utils.rb +24 -6
- data/lib/infopark/aws_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '078a203a9cd8bfd2dacafae006a0f6213516b453'
|
4
|
+
data.tar.gz: 54cd52b74fb99e9300bde91bcb8b5fc5c45f3cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fe7638fd74cd1f20e0bf87f9ecc459f169fd4897b435cb84d3b9c68f6920b4c1d45766ea9f923fe8b3d86e1267349ab419c27cf3d046917c7e79eeff1a494aa
|
7
|
+
data.tar.gz: 5a9571e4cf734b3a7ebd95df8a84abe0ab344d606fb8f65a40afdf1afa624bd6cb8066784590e0c10ea34535b47e082ea89aa5ab098394f03edc3f79e9e949d7
|
data/lib/infopark/aws_utils.rb
CHANGED
@@ -7,23 +7,29 @@ module Infopark
|
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def gather_all(client, method, **options)
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
unless block_given?
|
11
|
+
@gather_cache ||= {}
|
12
|
+
cache_key = [client, method, options]
|
13
|
+
return @gather_cache[cache_key] if @gather_cache[cache_key]
|
14
|
+
end
|
13
15
|
|
14
16
|
result = []
|
15
17
|
loop do
|
16
|
-
response = client.send(method, **options)
|
18
|
+
response = retry_on_throttle { client.send(method, **options) }
|
17
19
|
key = (response.members - [:next_token, :failures]).first
|
18
20
|
if response.members.include?(:failures) && !response.failures.empty?
|
19
21
|
raise "Failed gathering all #{method}: #{response.failures}"
|
20
22
|
end
|
21
|
-
|
23
|
+
if block_given?
|
24
|
+
response[key].each {|entity| retry_on_throttle { yield entity } }
|
25
|
+
else
|
26
|
+
result += response[key]
|
27
|
+
end
|
22
28
|
unless options[:next_token] = response.members.include?(:next_token) && response.next_token
|
23
29
|
break
|
24
30
|
end
|
25
31
|
end
|
26
|
-
@gather_cache[cache_key] = result
|
32
|
+
@gather_cache[cache_key] = result unless block_given?
|
27
33
|
end
|
28
34
|
|
29
35
|
def wait_for(progress, client, waiter, delay: 2, max_attempts: 60, **waiter_params)
|
@@ -46,6 +52,18 @@ module Infopark
|
|
46
52
|
end
|
47
53
|
)
|
48
54
|
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def retry_on_throttle
|
59
|
+
yield
|
60
|
+
rescue => e
|
61
|
+
if e.class.name =~ /Throttl/
|
62
|
+
sleep 0.1
|
63
|
+
retry
|
64
|
+
end
|
65
|
+
raise
|
66
|
+
end
|
49
67
|
end
|
50
68
|
|
51
69
|
DEV_ACCOUNT_ID = ENV['INFOPARK_AWS_DEV_ACCOUNT_ID'] || self.local_config['dev_account_id']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark-aws_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilo Prütz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-applicationautoscaling
|