-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from Shopify/enhance_throttle_for_ns1
Add API rate limit for NS1 provider and bump up the version to 5.7.1
- Loading branch information
Showing
23 changed files
with
5,532 additions
and
6,243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'net/http' | ||
|
||
# Patch the method which retrieves headers for API rate limit dynamically | ||
module NS1::Transport | ||
class NetHttp | ||
def process_response(response) | ||
sleep(response.to_hash["x-ratelimit-period"].first.to_i / | ||
[1, response.to_hash["x-ratelimit-remaining"].first.to_i].max.to_f) | ||
|
||
body = JSON.parse(response.body) | ||
case response | ||
when Net::HTTPOK | ||
NS1::Response::Success.new(body, response.code.to_i) | ||
else | ||
NS1::Response::Error.new(body, response.code.to_i) | ||
end | ||
rescue JSON::ParserError | ||
raise NS1::Transport::ResponseParseError | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module RecordStore | ||
VERSION = '5.7.0'.freeze | ||
VERSION = '5.7.1'.freeze | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
378 changes: 306 additions & 72 deletions
378
test/fixtures/vcr_cassettes/ns1_add_alias_changeset.yml
Large diffs are not rendered by default.
Oops, something went wrong.
433 changes: 163 additions & 270 deletions
433
test/fixtures/vcr_cassettes/ns1_add_caa_changeset.yml
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
28 changes: 16 additions & 12 deletions
28
test/fixtures/vcr_cassettes/ns1_add_changeset_missing_zone.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.