record_store 6.1.1 → 6.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml +2 -2
- data/lib/record_store/provider.rb +30 -0
- data/lib/record_store/provider/dnsimple.rb +13 -9
- data/lib/record_store/provider/ns1.rb +6 -2
- data/lib/record_store/provider/ns1/patch_api_header.rb +11 -4
- data/lib/record_store/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d05ecb06f048975b797baa10df042222f03ee4f0b1b5e268afa87e97b16ede6
|
4
|
+
data.tar.gz: 4ca96a597c88f5d17df9f85ea50e8743b0cab6fa4d57196447d3808cc22711a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98581b53f61499cb2f83d92ae2de4cf132ce2784cf56f8dc81531228f4090995f8e7a5a2c70f0a8fcac0cc5a3bdea29dd5c1d7b6996eef61e416c0c65c6a252d
|
7
|
+
data.tar.gz: 8e753593bc358e83f82a0191f07528e14aa793305570afae5fcc865e1bdd97fffb48319fec43642e662c7b62e1070dd3b384464b9ca55a39e2a590fcf0f6738b
|
@@ -671,7 +671,7 @@ Style/LineEndConcatenation:
|
|
671
671
|
Style/MethodCallWithoutArgsParentheses:
|
672
672
|
Enabled: true
|
673
673
|
|
674
|
-
|
674
|
+
Lint/MissingSuper:
|
675
675
|
Enabled: true
|
676
676
|
|
677
677
|
Style/MissingRespondToMissing:
|
@@ -964,7 +964,7 @@ Lint/UselessAccessModifier:
|
|
964
964
|
Lint/UselessAssignment:
|
965
965
|
Enabled: true
|
966
966
|
|
967
|
-
Lint/
|
967
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
968
968
|
Enabled: true
|
969
969
|
|
970
970
|
Lint/UselessElseWithoutRescue:
|
@@ -128,6 +128,36 @@ module RecordStore
|
|
128
128
|
|
129
129
|
dns.getresource(zone_name, Resolv::DNS::Resource::IN::SOA).mname.to_s
|
130
130
|
end
|
131
|
+
|
132
|
+
def retry_on_connection_errors(
|
133
|
+
max_timeouts: 5,
|
134
|
+
max_conn_resets: 5,
|
135
|
+
delay: 1,
|
136
|
+
backoff_multiplier: 2,
|
137
|
+
max_backoff: 10
|
138
|
+
)
|
139
|
+
loop do
|
140
|
+
begin
|
141
|
+
return yield
|
142
|
+
rescue Net::OpenTimeout
|
143
|
+
raise if max_timeouts <= 0
|
144
|
+
max_timeouts -= 1
|
145
|
+
|
146
|
+
$stderr.puts("Retrying after a connection timeout")
|
147
|
+
rescue Errno::ECONNRESET
|
148
|
+
raise if max_conn_resets <= 0
|
149
|
+
max_conn_resets -= 1
|
150
|
+
|
151
|
+
$stderr.puts("Retrying in #{delay}s after a connection reset")
|
152
|
+
backoff_sleep(delay)
|
153
|
+
delay = [delay * backoff_multiplier, max_backoff].min
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def backoff_sleep(delay)
|
159
|
+
sleep(delay)
|
160
|
+
end
|
131
161
|
end
|
132
162
|
end
|
133
163
|
end
|
@@ -14,19 +14,23 @@ module RecordStore
|
|
14
14
|
|
15
15
|
# returns an array of Record objects that match the records which exist in the provider
|
16
16
|
def retrieve_current_records(zone:, stdout: $stdout)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
retry_on_connection_errors do
|
18
|
+
session.zones.all_records(account_id, zone).data.map do |record|
|
19
|
+
begin
|
20
|
+
build_from_api(record, zone)
|
21
|
+
rescue StandardError
|
22
|
+
stdout.puts "Cannot build record: #{record}"
|
23
|
+
raise
|
24
|
+
end
|
25
|
+
end.compact
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
# Returns an array of the zones managed by provider as strings
|
28
30
|
def zones
|
29
|
-
|
31
|
+
retry_on_connection_errors do
|
32
|
+
session.zones.all_zones(account_id).data.map(&:name)
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
36
|
private
|
@@ -60,14 +60,18 @@ module RecordStore
|
|
60
60
|
|
61
61
|
# Returns an array of the zones managed by provider as strings
|
62
62
|
def zones
|
63
|
-
|
63
|
+
retry_on_connection_errors do
|
64
|
+
client.zones.map { |zone| zone['zone'] }
|
65
|
+
end
|
64
66
|
end
|
65
67
|
|
66
68
|
private
|
67
69
|
|
68
70
|
# Fetches simplified records for the provided zone
|
69
71
|
def records_for_zone(zone)
|
70
|
-
|
72
|
+
retry_on_connection_errors do
|
73
|
+
client.zone(zone)['records']
|
74
|
+
end
|
71
75
|
end
|
72
76
|
|
73
77
|
# Creates a new record to the zone. It is expected this call modifies external state.
|
@@ -4,12 +4,19 @@ require_relative '../provider_utils/rate_limit'
|
|
4
4
|
# Patch the method which retrieves headers for API rate limit dynamically
|
5
5
|
module NS1::Transport
|
6
6
|
class NetHttp
|
7
|
+
X_RATELIMIT_PERIOD = 'x-ratelimit-period'.freeze
|
8
|
+
X_RATELIMIT_REMAINING = 'x-ratelimit-remaining'.freeze
|
9
|
+
|
7
10
|
def process_response(response)
|
8
|
-
|
9
|
-
|
11
|
+
response_hash = response.to_hash
|
12
|
+
|
13
|
+
if response_hash.key?(X_RATELIMIT_PERIOD) && response_hash.key?(X_RATELIMIT_REMAINING)
|
14
|
+
sleep_time = response_hash[X_RATELIMIT_PERIOD].first.to_i /
|
15
|
+
[1, response_hash[X_RATELIMIT_REMAINING].first.to_i].max.to_f
|
10
16
|
|
11
|
-
|
12
|
-
|
17
|
+
rate_limit = RateLimit.new('NS1')
|
18
|
+
rate_limit.sleep_for(sleep_time)
|
19
|
+
end
|
13
20
|
|
14
21
|
body = JSON.parse(response.body)
|
15
22
|
case response
|
data/lib/record_store/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: record_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1.
|
4
|
+
version: 6.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|