record_store 6.1.0 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6686f890657b7a250384d189c2c377519616711a8295f510bbb140abaefde22
4
- data.tar.gz: 00066a49bd826aded557ba3c0a6cb60216ce53feb0c33efd89de9ae7792a5d7c
3
+ metadata.gz: f7a5da9483eaf8ce4eb82e8d974fefe82f7f481cde945a45ec6ae204b02524dc
4
+ data.tar.gz: 51e681688b6cc80c851f801ad00bb07ccf473ea2fb0b1c8a8e722d3cbc2ec196
5
5
  SHA512:
6
- metadata.gz: 642f48f0c639da2f9c3f5cb16bc3265504c647797586bbc6d7aa06f3667dbfaefe8977a4744f8a390ffd7bb45b2567e0964e8e719793182bbca05ccb9143d1e2
7
- data.tar.gz: 34e8d630d6b53dc22370f1472cd292b218e79136772151c403b46cc4eb027aa9377beebd17524dac6b37d47645ed7597a756f40f78511ebf0f5678ea9a61c74d
6
+ metadata.gz: 502acb53fcef150d5cb5442414c47552fc199efe66012e85d30745ae25c8af326064283c855ba12f4cead5b6f7b09f5a97c0b3bd6a4de1a010bba15664954335
7
+ data.tar.gz: 491ee9ff80ccb35ceb7ffbe70776948cd459467df8c213917c08ac6830e249585dbd993849a44e413bd6fc8e38589601eab27601cf3061c9b51abd09a94898a0
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 6.1.1
4
+ - Emit messages when waiting for rate-limit to elapse for DNSimple and NS1 providers, so deployment does not timeout [BUGFIX]
5
+
3
6
  ## 6.1.0
4
7
  - sort zone files [FEATURE]
5
8
  - CLI support for specifying zones for validate_authority [FEATURE]
@@ -1,15 +1,17 @@
1
+ require_relative '../provider_utils/rate_limit'
2
+
1
3
  # Patch Dnsimple client method which retrieves headers for API rate limit dynamically
2
4
  module Dnsimple
3
5
  class Client
4
6
  def execute(method, path, data = nil, options = {})
5
7
  response = request(method, path, data, options)
6
- rate_limit_sleep(response.headers["x-ratelimit-reset"].to_i, response.headers["x-ratelimit-remaining"].to_i)
8
+ rate_limit_sleep(response.headers['x-ratelimit-reset'].to_i, response.headers['x-ratelimit-remaining'].to_i)
7
9
 
8
10
  case response.code
9
11
  when 200..299
10
12
  response
11
13
  when 401
12
- raise AuthenticationFailed, response["message"]
14
+ raise AuthenticationFailed, response['message']
13
15
  when 404
14
16
  raise NotFoundError, response
15
17
  else
@@ -22,9 +24,10 @@ module Dnsimple
22
24
  def rate_limit_sleep(rate_limit_reset, rate_limit_remaining)
23
25
  rate_limit_reset_in = [0, rate_limit_reset - Time.now.to_i].max
24
26
  rate_limit_periods = rate_limit_remaining + 1
25
- wait_time = rate_limit_reset_in / rate_limit_periods.to_f
27
+ sleep_time = rate_limit_reset_in / rate_limit_periods.to_f
26
28
 
27
- sleep(wait_time) if wait_time > 0
29
+ rate_limit = RateLimit.new('DNSimple')
30
+ rate_limit.sleep_for(sleep_time)
28
31
  end
29
32
  end
30
33
  end
@@ -1,11 +1,15 @@
1
1
  require 'net/http'
2
+ require_relative '../provider_utils/rate_limit'
2
3
 
3
4
  # Patch the method which retrieves headers for API rate limit dynamically
4
5
  module NS1::Transport
5
6
  class NetHttp
6
7
  def process_response(response)
7
- sleep(response.to_hash["x-ratelimit-period"].first.to_i /
8
- [1, response.to_hash["x-ratelimit-remaining"].first.to_i].max.to_f)
8
+ sleep_time = response.to_hash['x-ratelimit-period'].first.to_i /
9
+ [1, response.to_hash['x-ratelimit-remaining'].first.to_i].max.to_f
10
+
11
+ rate_limit = RateLimit.new('NS1')
12
+ rate_limit.sleep_for(sleep_time)
9
13
 
10
14
  body = JSON.parse(response.body)
11
15
  case response
@@ -0,0 +1,14 @@
1
+ class RateLimit
2
+ def initialize(provider)
3
+ @provider = provider
4
+ end
5
+
6
+ def sleep_for(sleep_time)
7
+ while sleep_time > 0
8
+ wait = [10, sleep_time].min
9
+ puts "Waiting on #{@provider} rate-limit" if wait > 1
10
+ sleep(wait)
11
+ sleep_time -= wait
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module RecordStore
2
- VERSION = '6.1.0'.freeze
2
+ VERSION = '6.1.1'.freeze
3
3
  end
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.0
4
+ version: 6.1.1
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-05-21 00:00:00.000000000 Z
12
+ date: 2020-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -362,6 +362,7 @@ files:
362
362
  - lib/record_store/provider/ns1/client.rb
363
363
  - lib/record_store/provider/ns1/patch_api_header.rb
364
364
  - lib/record_store/provider/oracle_cloud_dns.rb
365
+ - lib/record_store/provider/provider_utils/rate_limit.rb
365
366
  - lib/record_store/record.rb
366
367
  - lib/record_store/record/a.rb
367
368
  - lib/record_store/record/aaaa.rb