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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7a5da9483eaf8ce4eb82e8d974fefe82f7f481cde945a45ec6ae204b02524dc
|
4
|
+
data.tar.gz: 51e681688b6cc80c851f801ad00bb07ccf473ea2fb0b1c8a8e722d3cbc2ec196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 502acb53fcef150d5cb5442414c47552fc199efe66012e85d30745ae25c8af326064283c855ba12f4cead5b6f7b09f5a97c0b3bd6a4de1a010bba15664954335
|
7
|
+
data.tar.gz: 491ee9ff80ccb35ceb7ffbe70776948cd459467df8c213917c08ac6830e249585dbd993849a44e413bd6fc8e38589601eab27601cf3061c9b51abd09a94898a0
|
data/CHANGELOG.md
CHANGED
@@ -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[
|
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[
|
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
|
-
|
27
|
+
sleep_time = rate_limit_reset_in / rate_limit_periods.to_f
|
26
28
|
|
27
|
-
|
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
|
-
|
8
|
-
|
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
|
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.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-
|
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
|