autoscaler 0.13.0 → 0.14.0
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/CHANGELOG.md +6 -1
- data/README.md +4 -6
- data/examples/complex.rb +8 -8
- data/examples/simple.rb +1 -1
- data/lib/autoscaler/heroku_platform_scaler.rb +12 -2
- data/lib/autoscaler/heroku_scaler.rb +4 -0
- data/lib/autoscaler/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec6a1b37ad89976bcf80edccfd67480c72aee6f0
|
4
|
+
data.tar.gz: c94e28fe7bcd92502be6dbee2cd9fd45b2ecbcb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6885e017918b53921cffb12aff92b59579ea1023d41f4f5bc5828d6f50dda383a92b5ca8c6320905b72b30bd37bced45c5c39b31d20bfc6647b4f6531fca5733
|
7
|
+
data.tar.gz: 7c3c78d2c162e50a4432e95ea907c39977a5b07fb44433d5d84bfc35dcb9ae75dcddadaff765d67b3b2d3e379046d950aaefd679516e1e04d6bd594655cab8c6
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.14.0
|
4
|
+
|
5
|
+
- Heroku has claimed the `HEROKU_` ENV prefix for Herkou-16 stack. The preferred variables are now `AUTOSCALER_HEROKU_APP` and `AUTOSCALER_HEROKU_ACCESS_TOKEN`. (The complex example has been similarly updated.) The old ENV variables will still be accepted, with a warning, but may be removed in a major release. (HerokuScaler was not updated.)
|
6
|
+
- Added an obsolescence warning to HerokuScaler, since the old API is no longer available. It may be removed in a major release.
|
7
|
+
|
3
8
|
## 0.13.0
|
4
9
|
|
5
10
|
- Update version spec to Sidekiq 5
|
6
|
-
- redis gem
|
11
|
+
- redis gem implements `call` for something else since 3.3.0, which was confusing duck sniffing.
|
7
12
|
|
8
13
|
## 0.12.0
|
9
14
|
|
data/README.md
CHANGED
@@ -14,10 +14,8 @@ Tested on Ruby 2.1.7 and Heroku Cedar stack.
|
|
14
14
|
|
15
15
|
This gem uses the [Heroku Platform-Api](https://github.com/heroku/platform-api) gem, which requires an OAuth token from Heroku. It will also need the heroku app name. By default, these are specified through environment variables. You can also pass them to `HerokuPlatformScaler` explicitly.
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
Support is still present for [Heroku-Api](https://github.com/heroku/heroku.rb) via `HerokuScaler` and `HEROKU_API_KEY`, but may be removed in a future major version.
|
17
|
+
AUTOSCALER_HEROKU_ACCESS_TOKEN=.....
|
18
|
+
AUTOSCALER_HEROKU_APP=....
|
21
19
|
|
22
20
|
Install the middleware in your `Sidekiq.configure_` blocks
|
23
21
|
|
@@ -65,9 +63,9 @@ You can pass a scaling strategy object instead of the timeout to the server midd
|
|
65
63
|
|
66
64
|
The project is setup to run RSpec with Guard. It expects a redis instance on a custom port, which is started by the Guardfile.
|
67
65
|
|
68
|
-
The HerokuPlatformScaler is not tested by default because it makes live API requests. Specify `
|
66
|
+
The HerokuPlatformScaler is not tested by default because it makes live API requests. Specify `AUTOSCALER_HEROKU_APP` and `AUTOSCALER_HEROKU_ACCESS_TOKEN` on the command line, and then watch your app's logs.
|
69
67
|
|
70
|
-
|
68
|
+
AUTOSCALER_HEROKU_APP=... AUTOSCALER_HEROKU_ACCESS_TOKEN=... guard
|
71
69
|
heroku logs --app ...
|
72
70
|
|
73
71
|
## Authors
|
data/examples/complex.rb
CHANGED
@@ -5,7 +5,7 @@ require 'autoscaler/heroku_platform_scaler'
|
|
5
5
|
# This setup is for multiple queues, where each queue has a dedicated process type
|
6
6
|
|
7
7
|
heroku = nil
|
8
|
-
if ENV['
|
8
|
+
if ENV['AUTOSCALER_HEROKU_APP']
|
9
9
|
heroku = {}
|
10
10
|
scaleable = %w[default import] - (ENV['ALWAYS'] || '').split(' ')
|
11
11
|
scaleable.each do |queue|
|
@@ -13,8 +13,8 @@ if ENV['HEROKU_APP']
|
|
13
13
|
# same as the queue name
|
14
14
|
heroku[queue] = Autoscaler::HerokuPlatformScaler.new(
|
15
15
|
queue,
|
16
|
-
ENV['
|
17
|
-
ENV['
|
16
|
+
ENV['AUTOSCALER_HEROKU_ACCESS_TOKEN'],
|
17
|
+
ENV['AUTOSCALER_HEROKU_APP'])
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -26,16 +26,16 @@ Sidekiq.configure_client do |config|
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
# define
|
29
|
+
# define AUTOSCALER_HEROKU_PROCESS in the Procfile:
|
30
30
|
#
|
31
|
-
# default: env
|
32
|
-
# import: env
|
31
|
+
# default: env AUTOSCALER_HEROKU_PROCESS=default bundle exec sidekiq -r ./background/boot.rb
|
32
|
+
# import: env AUTOSCALER_HEROKU_PROCESS=import bundle exec sidekiq -q import -c 1 -r ./background/boot.rb
|
33
33
|
|
34
34
|
Sidekiq.configure_server do |config|
|
35
35
|
config.server_middleware do |chain|
|
36
|
-
if heroku && ENV['
|
36
|
+
if heroku && ENV['AUTOSCALER_HEROKU_PROCESS'] && heroku[ENV['AUTOSCALER_HEROKU_PROCESS']]
|
37
37
|
p "Setting up auto-scaledown"
|
38
|
-
chain.add(Autoscaler::Sidekiq::Server, heroku[ENV['
|
38
|
+
chain.add(Autoscaler::Sidekiq::Server, heroku[ENV['AUTOSCALER_HEROKU_PROCESS']], 60, [ENV['AUTOSCALER_HEROKU_PROCESS']]) # 60 second timeout
|
39
39
|
else
|
40
40
|
p "Not scaleable"
|
41
41
|
end
|
data/examples/simple.rb
CHANGED
@@ -5,7 +5,7 @@ require 'autoscaler/heroku_platform_scaler'
|
|
5
5
|
# This is setup for a single queue (default) and worker process (worker)
|
6
6
|
|
7
7
|
heroku = nil
|
8
|
-
if ENV['
|
8
|
+
if ENV['AUTOSCALER_HEROKU_APP']
|
9
9
|
heroku = Autoscaler::HerokuPlatformScaler.new
|
10
10
|
#heroku.exception_handler = lambda {|exception| MyApp.logger.error(exception)}
|
11
11
|
end
|
@@ -9,8 +9,18 @@ module Autoscaler
|
|
9
9
|
# @param [String] app Heroku app name
|
10
10
|
def initialize(
|
11
11
|
type = 'worker',
|
12
|
-
token = ENV['
|
13
|
-
app = ENV['
|
12
|
+
token = ENV['AUTOSCALER_HEROKU_ACCESS_TOKEN'],
|
13
|
+
app = ENV['AUTOSCALER_HEROKU_APP'])
|
14
|
+
|
15
|
+
if (token.nil? && ENV['HEROKU_ACCESS_TOKEN'])
|
16
|
+
warn "Autoscaler: ENV AUTOSCALER_HEROKU_ACCESS_TOKEN is now preferred, HEROKU_ACCESS_TOKEN may be removed in a future release"
|
17
|
+
token = ENV['HEROKU_ACCESS_TOKEN']
|
18
|
+
end
|
19
|
+
if (app.nil? && ENV['HEROKU_APP'])
|
20
|
+
warn "Autoscaler: ENV AUTOSCALER_HEROKU_APP is now preferred, HEROKU_APP may be removed in a future release"
|
21
|
+
app = ENV['HEROKU_APP']
|
22
|
+
end
|
23
|
+
|
14
24
|
@client = PlatformAPI.connect_oauth(token)
|
15
25
|
@type = type
|
16
26
|
@app = app
|
@@ -3,6 +3,7 @@ require 'autoscaler/counter_cache_memory'
|
|
3
3
|
|
4
4
|
module Autoscaler
|
5
5
|
# Wraps the Heroku API to provide just the interface that we need for scaling.
|
6
|
+
# OBSOLETE: The v1 Heroku API is no longer available, and HerokuScaler will likely be removed in a future major release. Please see current setup instructions and examples for HerokuPlatformScaler.
|
6
7
|
class HerokuScaler
|
7
8
|
# @param [String] type process type this scaler controls
|
8
9
|
# @param [String] key Heroku API key
|
@@ -11,6 +12,9 @@ module Autoscaler
|
|
11
12
|
type = 'worker',
|
12
13
|
key = ENV['HEROKU_API_KEY'],
|
13
14
|
app = ENV['HEROKU_APP'])
|
15
|
+
|
16
|
+
warn "Autoscaler: The v1 Heroku API is no longer available, and HerokuScaler will likely be removed in a future major release. Please see current setup instructions and examples for HerokuPlatformScaler."
|
17
|
+
|
14
18
|
@client = Heroku::API.new(:api_key => key)
|
15
19
|
@type = type
|
16
20
|
@app = app
|
data/lib/autoscaler/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -6,7 +6,7 @@ RSpec.configure do |config|
|
|
6
6
|
config.mock_with :rspec
|
7
7
|
|
8
8
|
config.filter_run_excluding :api1 => true unless ENV['HEROKU_API_KEY']
|
9
|
-
config.filter_run_excluding :platform_api => true unless ENV['HEROKU_ACCESS_TOKEN']
|
9
|
+
config.filter_run_excluding :platform_api => true unless ENV['AUTOSCALER_HEROKU_ACCESS_TOKEN'] || ENV['HEROKU_ACCESS_TOKEN']
|
10
10
|
end
|
11
11
|
|
12
12
|
class TestScaler
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autoscaler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Love
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sidekiq
|