Skip to content

Commit 4db5277

Browse files
committed
Enable rate-throttling by default
As a followup from #103 this PR bumps the major platform-api version and enables rate-throttling by default.
1 parent 2ec6a69 commit 4db5277

File tree

5 files changed

+7
-22
lines changed

5 files changed

+7
-22
lines changed

CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## 3.0.0
44

5-
- Rate throttling is on by default.
5+
- Rate throttling is on by default. (https://github.com/heroku/platform-api/pull/104)
66

77
## 2.3.0
88

9-
- Changes are now tracked in the CHANGELOG.md
10-
- Rate throttling is included by default but disabled.
9+
- Changes are now tracked in the CHANGELOG.md.
10+
- Rate throttling is included by default but disabled. (https://github.com/heroku/platform-api/pull/103)

config/client-config.rb

+1-10
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,7 @@
99
config.module_name = 'PlatformAPI'
1010
config.schema_filepath = File.join(File.expand_path('../..', __FILE__), 'schema.json')
1111

12-
PlatformAPI.rate_throttle = ->(&block) {
13-
@deprecate_on_first ||= begin
14-
message = String.new("[Warning] Starting in PlatformAPI version 3+, requests will include rate throttling logic\n")
15-
message << "to opt-out of this behavior set: `PlatformAPI.rate_throttle = RateThrottleClient::Null.new`\n"
16-
message << "to silence this warning and opt-in to this logic, upgrade to PlatformAPI version 3+"
17-
warn message
18-
true
19-
end
20-
block.call
21-
}
12+
PlatformAPI.rate_throttle = RateThrottleClient::ExponentialIncreaseProportionalRemainingDecrease.new
2213
config.rate_throttle = PlatformAPI.rate_throttle
2314
config.acceptable_status_codes = [429]
2415

lib/platform-api/client.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def self.custom_options(options)
8383

8484
# Get the default options.
8585
def self.default_options
86-
default_headers = {"Accept"=>"application/vnd.heroku+json; version=3", "User-Agent"=>"platform-api/2.3.0"}
86+
default_headers = {"Accept"=>"application/vnd.heroku+json; version=3", "User-Agent"=>"platform-api/3.0.0.pre.1"}
8787
{
8888
default_headers: default_headers,
8989
url: "https://api.heroku.com"

lib/platform-api/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module PlatformAPI
2-
VERSION = '2.3.0.pre.2'
2+
VERSION = '3.0.0.pre.1'
33
end

spec/acceptance/config_spec.rb

+1-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@original_rate_throttle = rate_throttle.dup
1212

1313
# No junk in test dots
14-
rate_throttle.log = ->(*_) {} if rate_throttle.respond_to?("log=")
14+
rate_throttle.log = ->(*_) {}
1515

1616
# Don't sleep in tests
1717
def rate_throttle.sleep(value); end
@@ -24,8 +24,6 @@ def rate_throttle.sleep(value); end
2424
end
2525

2626
it "works even if first request is rate limited" do
27-
skip("Default behavior changes in v3+") unless Gem::Version.new(PlatformAPI::VERSION) >= Gem::Version.new("3.0.0.beta")
28-
2927
stub_request(:get, "https://api.heroku.com/apps")
3028
.to_return([
3129
{status: 429},
@@ -46,10 +44,6 @@ def rate_throttle.sleep(value); end
4644
])
4745

4846
@retry_count = 0
49-
throttle = RateThrottleClient::ExponentialIncreaseProportionalRemainingDecrease.new
50-
def throttle.sleep(var); end
51-
52-
PlatformAPI.rate_throttle = throttle
5347
PlatformAPI.rate_throttle.log = ->(*_) { @retry_count += 1 }
5448
client.app.list
5549

0 commit comments

Comments
 (0)